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:
- Why do I get this "unrecognized selector"?
- 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.
精彩评论