簡體   English   中英

Xcode生成NSManagedObject子類錯誤

[英]Xcode generated NSManagedObject subclass errors

我的生成的模型對象有很多錯誤:

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
  • 第1行上的Illegal interface qualifier
  • Expected identifier or '('第3行上的Expected identifier or '('
  • 第8行的Unknown type name 'Exercise'
  • Property with 'retain (or strong)' attribute must be of object type第8行Property with 'retain (or strong)' attribute must be of object type
  • 警告所有屬性,不要調用@synthesize@dynamic (當然會調用它們)

運動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
  • 第1行上的Illegal interface qualifier
  • 在第3行上Missing @end
  • 第9行的Unknown type name 'Workout'
  • 等等

其他向前聲明的接口都可以,沒有問題或錯誤。

是什么導致這種現象?

我只是遇到了同樣的問題,結果是我的.h文件之一丟失了@end這也是為什么重新生成NSManagedObjects的原因。

您能在這里介紹如何定義鍛煉嗎? 您的代碼似乎正確,但似乎在類練習中出錯

同時嘗試更改

@class Exercise

對於:

#import "Exercise.h"

我升級到Xcode 4.3,重新生成了NSManagedObject子類,錯誤消失了。 它一定是Xcode中的錯誤。

無論如何,謝謝您的幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM