【发布时间】:2013-03-14 20:57:40
【问题描述】:
已解决:原来我导入了包含该类别的错误头文件。
我收到此错误:Property 'xx_store' not found on object of type 'XXFeedback *'
然而,XXFeedback 是 NSManagedObject 的子类,我在其中添加了一个类别,该类别添加了 xx_store 方法。
我已确保该类别的实现文件包含在我的目标的编译源构建阶段。
我还尝试在目标的构建设置中添加这些“其他链接器标志”设置:-ObjC 和 -all_load,根据 Building Objective-C static libraries with categories
我还清理并重建了一个项目。
代码
在XXFoundation/FileA.h:
@interface NSManagedObject (MyCategory)
@property (readonly, nonatomic) XXStore *xx_store;
@end
在XXFoundation/FileA.m:
@implementation NSManagedObject (MyCategory)
- (XXStore *)xx_store
{
...
}
在 FileB.m 中:
#import <XXFoundation/FileA.h>
...
XXStore *store = _feedback.xx_store;
...
【问题讨论】:
-
XXFeedback 的 .h #include NSManagedObject+MyCategory 吗?我没有看到你的 XXFeedback 声明。
-
XXFeedback不需要,因为它是NSManagedObject的子类,并且NSManagedObject上的类别包含在我使用XXFeedback实例的文件中。跨度> -
需要在 FileB.m 的某处有一个类别声明的#import,以便编译器在编译 FileB.m 时知道该方法。 #import 可能在 FileB.m 中,或者它导入的东西或它的导入导入的东西,等等。
-
在 FileB.m 中你有一个 FileA.h 的导入,这是一个错字吗?不应该是导入 FileB.h 吗?
标签: objective-c implementation