开发者

getting "unrecognized selector" when trying to use Core Data managed object XCode generated class in unit test?

Why am I getting "unrecognized selector" when trying to use Core Data managed object XCode generated class in unit test?

That is, in the test case I have to path the method an instanced of a core data managed object (I'm using Xcode 4 generated managed objects). To aid in keeping the test light weight I through I could just create the object myself (not using the core data framework). Seemed OK however when I try to use the properties I get "unrecognized selector".

Question are I guess:

  1. Why do I get this "unrecognized selector"?
  2. How can I modify what I'm doing to create a lightweight version of my core data managed object to be used as input to a method under test in a unit test?

Example of code from managed object. Eg here using the property "title" would trigger the issue:

@interface WEView : NSManagedObject {
  @private
}
  @property (nonatomic, retain) 开发者_开发知识库NSString * title;
@end


#import "WEView.h"
@implementation WEView
   @dynamic title;
@end


The @dynamic preprocessor command tells the compiler that the methods will be provided at runtime. It is the managed object context that provides the methods based on information taken from the managed object model. Without the context, the class doesn't have the actual method and can't respond to the selector.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜