简体   繁体   中英

Xcode generated NSManagedObject subclass errors

I'm having a ton of errors for my generated model objects:

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.
  • Expected identifier or '(' on line 3.
  • Unknown type name 'Exercise' on line 8
  • Property with 'retain (or strong)' attribute must be of object type on line 8.
  • Warning for all properties for not calling @synthesize , or @dynamic (which of course are called)

Exercise.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.
  • Missing @end on line 3.
  • Unknown type name 'Workout' on line 9.
  • 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. It must've been a bug in Xcode.

Thanks for your help anyways!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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