EXC_BAD_ACCESS when accessing parameters in andDo of OCMock

前端 未结 3 1055
终归单人心
终归单人心 2021-02-07 11:37

I am trying to write an block of code using OCMock\'s stub andDo method.

In this case UIImageView extension class is being tested. I want to check that the exte

3条回答
  •  野的像风
    2021-02-07 12:10

    I ran into a similar problem when using NSProxy's forwardInvocation: method.

    Can you try the below?

    NSInvocationOperation *op; // Change this line
    __unsafe_unretained NSInvocationOperation *op; // to this line
    

    Or another approach could be to retain NSInvocation's arguments:

    [invocation retainArguments];
    

    http://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSInvocation_Class/Reference/Reference.html#//apple_ref/occ/instm/NSInvocation/retainArguments

    I'll try to add a more detailed explanation later.

提交回复
热议问题