Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c Xcode生成的NSManagedObject子类错误_Objective C_Ios_Core Data_Xcode4 - Fatal编程技术网

Objective c Xcode生成的NSManagedObject子类错误

Objective c Xcode生成的NSManagedObject子类错误,objective-c,ios,core-data,xcode4,Objective C,Ios,Core Data,Xcode4,生成的模型对象有大量错误: 练习集 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 @prope

生成的模型对象有大量错误:

练习集

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行的非法接口限定符
  • 第3行的预期标识符或“(”
  • 未知类型名称“练习”
    第8行
  • 具有“retain(或strong)”属性的属性必须是第8行的对象类型
  • 警告所有属性不调用
    @synthesis
    @dynamic
    (当然是调用的)
练习

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行的非法接口限定符
  • 第3行缺少@end
  • 第9行的未知类型名称“训练”
  • 等等
其他前向声明的接口正常,没有问题或错误


什么会导致这种行为?

您能在这里说明练习是如何定义的吗?您的代码似乎正确,但在类练习中似乎有错误

同时尝试改变

@class Exercise
用于:


我升级到Xcode 4.3,重新生成了
NSManagedObject
子类,错误消失了。这一定是Xcode中的一个bug


无论如何谢谢你的帮助!

我也遇到了同样的问题,结果发现我的一个.h文件丢失了
@end

这也是重新生成NSManagedObject有效的原因。

我可以用NSObject而不是NSManagedObject编译您的代码,我不知道它是否适用于您
#import "Exercise.h"