【问题标题】:fetch all object from coredata in one-to-many relationship以一对多关系从 coredata 中获取所有对象
【发布时间】:2012-05-26 11:19:13
【问题描述】:

这是我的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 创建的
如何在每个练习中通过listQuestion 获取所有Question 对象

【问题讨论】:

    标签: objective-c database core-data


    【解决方案1】:

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

    NSArray *questions = [[exercise listQuestion] allObjects];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-16
      • 2014-07-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多