【问题标题】:Class does not implement doesNotRecognizeSelector类没有实现 doesNotRecognizeSelector
【发布时间】:2013-06-11 12:35:33
【问题描述】:

我有一个简单的循环:

   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];

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

【问题讨论】:

    标签: ios cocoa-touch core-data restkit


    【解决方案1】:

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

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

    【讨论】:

    • 确实非常糟糕的命名选择
    • 非常感谢!我盲目地复制了架构!!
    • @Sulthan 这很有趣。你知道那个类是做什么用的吗?它有一个isa 指针,以及我通过反射找到的retain releaseautorelease 方法,但是我在任何地方都找不到声明的接口。
    • @borrrden 我很确定这是一个已弃用的根类。早于NSObject。我认为它已从标题中删除。
    • @borrrden objc/Object.h
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-31
    • 2015-11-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多