类未实现didNotRecognizeSelector

类未实现didNotRecognizeSelector

我有一个简单的循环:

   for(Object_ *obj in not.object)
   {
        ......
        Object *objStor = [NSEntityDescription insertNewObjectForEntityForName:@"Object" inManagedObjectContext:context];
        .....
    }


“ Object_”类的接口如下:

@interface Object_ : NSObject
@property (nonatomic, strong) NSNumber * id;
@property (nonatomic, strong) NSString * name;
@property (nonatomic, strong) NSNumber * review_id;
.
.
.
.
@end


“对象”类的接口(由xCode为核心数据架构创建)看起来像:

@interface Object : NSManagedObject

@property (nonatomic, retain) NSNumber * id;
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSNumber * rating;
.
.
.
.
@end


我收到一个错误:

*** NSForwarding: warning: object 0x1a1bb48 of class 'Object' does not implement methodSignatureForSelector: -- trouble ahead
*** NSForwarding: warning: object 0x1a1bb48 of class 'Object' does not implement doesNotRecognizeSelector: -- abort


在线解决方案说将“ Object”类声明为NSObject的子类。但是我无法更改对NSObject的继承,因为这会导致Core Data Model失败。

我的上方还有另一条线,

Subject *subStor = [NSEntityDescription insertNewObjectForEntityForName:@"Subject" inManagedObjectContext:context];


效果很好。
是什么导致错误?

最佳答案

我猜你有一个命名空间冲突。 Obj-C有一个名为Object的类,它将与您的Object类发生冲突。

将您的Object重命名为其他名称。

关于ios - 类未实现didNotRecognizeSelector,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17044255/

10-11 23:17