"unrecognized selector" on block callback

Discussion of the OCMock framework. If you have patches we would prefer you to send them to the mailing list, but attaching them to a topic is possible, too.

"unrecognized selector" on block callback

Postby wile_e_coyote » 03 Jun 2014, 17:03

Thanks in advance for any help you can provide with this...

I'm trying to use OCMock to mock a method that accepts a block parameter and its crashing with an "unrecognized selector". My method is declared as

(void)theMethod:(void(^)(BOOL completed))completionBlock;
When I attempt to mock it

myMock = [OCMockObject niceMockForClass:[myClass class]];

void (^proxyBlock)(NSInvocation *) = ^(NSInvocation *invocation) {
void (^passedBlock)( BOOL );
[invocation getArgument: &passedBlock atIndex: 2];
};
[[[myMock stub] andDo: proxyBlock] theMethod:[OCMArg any]]; //<<-- crashes here

Note: based on this thread, I'm wondering if this is only an issue under iOS7: http://www.mulle-kybernetik.com/forum/viewtopic.php?f=4&t=304&p=709&hilit=block#p709


It crashes with an unrecognized selector on CopyWithZone

2014-06-02 10:32:44.227 myProject[47409:60b] -[OCMAnyConstraint copyWithZone:]: unrecognized selector sent to instance 0x8c4e850 :0: error: -[myProjectTests testExample] : -[OCMAnyConstraint copyWithZone:]: unrecognized selector sent to instance 0x8c4e850

myClass has no public or private properties or variables (it just contains methods).
wile_e_coyote
 
Posts: 2
Joined: 03 Jun 2014, 17:00

Re: "unrecognized selector" on block callback

Postby wile_e_coyote » 03 Jun 2014, 20:37

Turns out that I was using an old version of OCMock. This behavior is fixed in OCMock 2.2.4.
wile_e_coyote
 
Posts: 2
Joined: 03 Jun 2014, 17:00


Return to OCMock



cron