2012-05-26 53 views
1

這是我Exercise獲取來自coredata所有對象在一個一對多的關係

@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
創建的類我怎樣才能通過listQuestion獲得全部Question對象每次練習

回答

4

Thi s會給你一個給定練習的所有Question對象的數組:

NSArray *questions = [[exercise listQuestion] allObjects]; 
相關問題