mardi 21 avril 2015

OCMock [OCMAnyConstraint isProxy]: message sent to deallocated instance, what's happening?

I'm attempting to do a straightforward mock of an object,

HTAppleWatchDevice * shared = [[HTAppleWatchDevice alloc] init];
id watchMock = [OCMockObject partialMockForObject:shared];
[deviceManager setAppleWatchDevice:watchMock];

void (^replyDict)(NSDictionary*) = ^void(NSDictionary* response){};

[[watchMock expect] dataReturnedFromServer:[OCMArg isNotNil] ofType:[OCMArg any]];
[watchMock handleWatchKitExtensionRequest:request reply:replyDict];
[watchMock verifyWithDelay:10];

Indeed the expected method is called, but I get this sort of error, depending on the second OCMArg:

[OCMAnyConstraint isProxy]: message sent to deallocated instance 0x7f954608b630

I've literally tried putting the expected call FIRST in handleWatchKitExtensionRequest:reply:, with dummy data, but the exact same error occurs.

[self dataReturnedFromServer:@[] ofType:[self supportedMIMETypes].firstObject];

Any ideas?

Aucun commentaire:

Enregistrer un commentaire