核心数据自定义类未知链接器错误

发布于 2024-10-09 05:19:18 字数 2306 浏览 4 评论 0 原文

大家好,我一直在引用这个项目,但我收到此链接器错误:

Undefined symbols:
  "_OBJC_CLASS_$_NSManagedObject", referenced from:
      _OBJC_CLASS_$_ParkingLot in ParkingLot.o
      _OBJC_CLASS_$_Permit in Permit.o
  "_OBJC_METACLASS_$_NSManagedObject", referenced from:
      _OBJC_METACLASS_$_ParkingLot in ParkingLot.o
      _OBJC_METACLASS_$_Permit in Permit.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

这是相关代码(我按照 this[向下滚动到“自定义托管对象类”]):

//Permit.h
#import <CoreData/CoreData.h>

@class ParkingLot;

@interface Permit :  NSManagedObject  
{
}

@property (nonatomic, retain) NSString * eligibility;
@property (nonatomic, retain) NSString * pricing;
@property (nonatomic, retain) NSString * type;
@property (nonatomic, retain) NSString * summary;
@property (nonatomic, retain) NSString * timeValid;
@property (nonatomic, retain) NSSet* parkingLots;

@end


@interface Permit (CoreDataGeneratedAccessors)
- (void)addParkingLotsObject:(ParkingLot *)value;
- (void)removeParkingLotsObject:(ParkingLot *)value;
- (void)addParkingLots:(NSSet *)value;
- (void)removeParkingLots:(NSSet *)value;

@end

//Permit.m
#import "Permit.h"

#import "ParkingLot.h"

@implementation Permit 

@dynamic eligibility;
@dynamic pricing;
@dynamic type;
@dynamic summary;
@dynamic timeValid;
@dynamic parkingLots;

@end

//ParkingLot.h
#import <CoreData/CoreData.h>


@interface ParkingLot :  NSManagedObject  
{
}

@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) id region;
@property (nonatomic, retain) NSSet* permits;

@end


@interface ParkingLot (CoreDataGeneratedAccessors)
- (void)addPermitsObject:(NSManagedObject *)value;
- (void)removePermitsObject:(NSManagedObject *)value;
- (void)addPermits:(NSSet *)value;
- (void)removePermits:(NSSet *)value;

@end

//ParkingLot.m
#import "ParkingLot.h"


@implementation ParkingLot 

@dynamic title;
@dynamic region;
@dynamic permits;

@end

如果您看一下我遵循的示例代码,它几乎是相同的,但它拒绝工作,我不明白为什么。预先感谢您的任何帮助!

Ey guys, I have been referencing this project, but I get this linker error:

Undefined symbols:
  "_OBJC_CLASS_$_NSManagedObject", referenced from:
      _OBJC_CLASS_$_ParkingLot in ParkingLot.o
      _OBJC_CLASS_$_Permit in Permit.o
  "_OBJC_METACLASS_$_NSManagedObject", referenced from:
      _OBJC_METACLASS_$_ParkingLot in ParkingLot.o
      _OBJC_METACLASS_$_Permit in Permit.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

Here is the relevant code(that I made following this[scroll down to "Custom Managed Object Class"]):

//Permit.h
#import <CoreData/CoreData.h>

@class ParkingLot;

@interface Permit :  NSManagedObject  
{
}

@property (nonatomic, retain) NSString * eligibility;
@property (nonatomic, retain) NSString * pricing;
@property (nonatomic, retain) NSString * type;
@property (nonatomic, retain) NSString * summary;
@property (nonatomic, retain) NSString * timeValid;
@property (nonatomic, retain) NSSet* parkingLots;

@end


@interface Permit (CoreDataGeneratedAccessors)
- (void)addParkingLotsObject:(ParkingLot *)value;
- (void)removeParkingLotsObject:(ParkingLot *)value;
- (void)addParkingLots:(NSSet *)value;
- (void)removeParkingLots:(NSSet *)value;

@end

//Permit.m
#import "Permit.h"

#import "ParkingLot.h"

@implementation Permit 

@dynamic eligibility;
@dynamic pricing;
@dynamic type;
@dynamic summary;
@dynamic timeValid;
@dynamic parkingLots;

@end

//ParkingLot.h
#import <CoreData/CoreData.h>


@interface ParkingLot :  NSManagedObject  
{
}

@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) id region;
@property (nonatomic, retain) NSSet* permits;

@end


@interface ParkingLot (CoreDataGeneratedAccessors)
- (void)addPermitsObject:(NSManagedObject *)value;
- (void)removePermitsObject:(NSManagedObject *)value;
- (void)addPermits:(NSSet *)value;
- (void)removePermits:(NSSet *)value;

@end

//ParkingLot.m
#import "ParkingLot.h"


@implementation ParkingLot 

@dynamic title;
@dynamic region;
@dynamic permits;

@end

If you take a look at the sample code I followed, it is pretty much identical, yet it refuses to work and I can't figure out why. Thanks in advance for any help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

缱绻入梦 2024-10-16 05:19:18

愚蠢的我......我需要将核心数据框架添加到我的项目中。我可以发誓我已经做到了这一点……这就是我在凌晨编程所得到的结果。

Stupid me... I needed to add the Core Data framework to my project. I could have sworn I had already done this... that's what I get for programming into the wee hours of the morning.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文