开发者

Cocoa-Touch, Core Data: Linker error, NSManagedObject symbol not found

开发者 https://www.devze.com 2022-12-08 10:07 出处:网络
I have a cocoa-touch app, using the core data framework. I\'ve created a xcdatamodel with two entities: Program and ProgramReplay.

I have a cocoa-touch app, using the core data framework.

I've created a xcdatamodel with two entities: Program and ProgramReplay.

ProgramReplay has a relationship to Program, and a reverse relationship exists in the later.

I've saved this, and used XCode's feature to generate the classes for these two entities. The generated headers are as follows:

#import <CoreData/CoreData.h>
@class ProgramReplay;
@interface Program :  NSManagedObject  
{
}

// other properties here, removed them to keep it short
@property (nonatomic, retain) NSSet* replays;
@end

@interface Program (CoreDataGeneratedAccessors)
- (void)addReplaysObject:(ProgramReplay *)value;
- (void)removeReplaysObject:(ProgramReplay *)value;
- (void)addReplays:(NSSet *)value;
- (void)removeReplays:(NSSet *)value;
@end

and

#import <CoreData/CoreData.h>
@class Program;
@interface ProgramReplay :  NSManagedObject  
{
}

@property (nonatomic, retain)开发者_运维知识库 NSDate * date;
@property (nonatomic, retain) Program * program;
@end

I haven't started using these two classes anywhere yet, but when I try to build them I get the following weird linking errors:

".objc_class_name_NSManagedObject", referenced from:

.objc_class_name_Program in Program.o

.objc_class_name_ProgramReplay in ProgramReplay.o

ld: symbol(s) not found

collect2: ld returned 1 exit status

What am I doing wrong?


It looks like you haven't linked in the CoreData framework. Make sure that "CoreData.framework" is part of the "Link binary with libraries" phase of the target you're building. Also add #import <CoreData/CoreData.h> in .h file.

0

精彩评论

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

关注公众号