简体   繁体   English

Xcode生成NSManagedObject子类错误

[英]Xcode generated NSManagedObject subclass errors

I'm having a ton of errors for my generated model objects: 我的生成的模型对象有很多错误:

ExerciseSet.h ExerciseSet.h

1  @class Exercise;
2 
3  @interface ExerciseSet : NSManagedObject
4 
5  @property (nonatomic, retain) NSNumber * order;
6  @property (nonatomic, retain) NSNumber * reps;
7  @property (nonatomic, retain) NSNumber * weight;
8  @property (nonatomic, retain) Exercise *belongsTo;
9
10 @end
  • Illegal interface qualifier on line 1. 第1行上的Illegal interface qualifier
  • Expected identifier or '(' on line 3. Expected identifier or '('第3行上的Expected identifier or '('
  • Unknown type name 'Exercise' on line 8 第8行的Unknown type name 'Exercise'
  • Property with 'retain (or strong)' attribute must be of object type on line 8. Property with 'retain (or strong)' attribute must be of object type第8行Property with 'retain (or strong)' attribute must be of object type
  • Warning for all properties for not calling @synthesize , or @dynamic (which of course are called) 警告所有属性,不要调用@synthesize@dynamic (当然会调用它们)

Exercise.h 运动h

1  @class ExerciseName, ExerciseSet, Workout, WorkoutMethod;
2
3  @interface Exercise : NSManagedObject
4
5  @property (nonatomic, retain) NSString * notes;
6  @property (nonatomic, retain) NSDecimalNumber * restBetweenSets;
7  @property (nonatomic, retain) NSNumber * rmMethod;
8  @property (nonatomic, retain) NSDecimalNumber * rmResult;
9  @property (nonatomic, retain) Workout *belongsTo;
10 @property (nonatomic, retain) NSSet *hasSet;
11 @property (nonatomic, retain) WorkoutMethod *isDoneWith;
12 @property (nonatomic, retain) ExerciseName *takesNameFrom;
13 @end
14 
15 @interface Exercise (CoreDataGeneratedAccessors)
16 
17 - (void)addHasSetObject:(ExerciseSet *)value;
18 - (void)removeHasSetObject:(ExerciseSet *)value;
19 - (void)addHasSet:(NSSet *)values;
20 - (void)removeHasSet:(NSSet *)values;
21 @end
  • Illegal interface qualifier on line 1. 第1行上的Illegal interface qualifier
  • Missing @end on line 3. 在第3行上Missing @end
  • Unknown type name 'Workout' on line 9. 第9行的Unknown type name 'Workout'
  • etc. 等等

The other forward declared interfaces are ok, with no problems or errors. 其他向前声明的接口都可以,没有问题或错误。

What could cause this behavior? 是什么导致这种现象?

我只是遇到了同样的问题,结果是我的.h文件之一丢失了@end这也是为什么重新生成NSManagedObjects的原因。

Can you put here how Exercise is being defined? 您能在这里介绍如何定义锻炼吗? Your code seem correct but it seems that you have an error on the class Exercise 您的代码似乎正确,但似乎在类练习中出错

Meantime try to change 同时尝试更改

@class Exercise

For: 对于:

#import "Exercise.h"

I upgraded to Xcode 4.3, regenerated the NSManagedObject subclasses and the errors disappeared. 我升级到Xcode 4.3,重新生成了NSManagedObject子类,错误消失了。 It must've been a bug in Xcode. 它一定是Xcode中的错误。

Thanks for your help anyways! 无论如何,谢谢您的帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM