1

这是我的Exercise

@class Question;

@interface Exercise : NSManagedObject

@property (nonatomic, retain) NSNumber * aID;
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSSet *listQuestion;
@end

@interface Exercise (CoreDataGeneratedAccessors)

- (void)addListQuestionObject:(Question *)value;
- (void)removeListQuestionObject:(Question *)value;
- (void)addListQuestion:(NSSet *)values;
- (void)removeListQuestion:(NSSet *)values;

@end 

这是Question上课

@class Exercise;

@interface Question : NSManagedObject

@property (nonatomic, retain) NSNumber * aID;
@property (nonatomic, retain) id jsAnswer;
@property (nonatomic, retain) Exercise *exercise;

@end

这些类是由 coredata 创建的
我如何在每个练习中获取所有Question对象listQuestion

4

1 回答 1

4

这将为您提供给定练习的所有 Question 对象的数组:

NSArray *questions = [[exercise listQuestion] allObjects];
于 2012-05-26T11:29:46.307 回答