OCMock with Core Data dynamic properties problem

前端 未结 3 800
天命终不由人
天命终不由人 2020-12-25 13:43

I\'m using OCMock to mock some Core Data objects. Previously, I had the properties implemented with Objective-C 1.0 style explicit accessors:

// -- Old Core          


        
3条回答
  •  误落风尘
    2020-12-25 14:46

    The above answer didn't satisfy me, because I didn't like to create a protocol for that. So I found out that there is an easier way to do that. Instead of

    [[[mockItem stub] andReturn:@"fakepath.pdf"] PDFName]; // <-- throws exception here
    

    Just write

    [[[mockItem stub] andReturn:@"fakepath.pdf"] valueForKey:@"PDFName"];
    

提交回复
热议问题