我正在使用 MagicalRecord 处理 Core Data 对象。我在使用 MR 将它们放入的 NSArray 检索核心数据对象时遇到问题……我似乎无法将数据从数组中取出并放入 NSManagedObject 中,因此我可以使用它。这是我的代码:
// create the predicate
NSArray *apptDataArray = [NSMutableArray new];
NSPredicate *predicate = ([NSPredicate predicateWithFormat:@"((aStartTime > %@) AND (aStartTime <= %@))", startDate, endDate]);
// find all appointments with that selected date
apptDataArray = [AppointmentInfo MR_findAllWithPredicate:predicate];
// now find the appointments for the selected date and put them in the schedule
if(apptDataArray.count > 0) {
for (NSManagedObject *AppointmentInfo in apptDataArray) {
NSLog(@"\n\n-->apptDataArray: %@", apptDataArray);
}
}
这是 AppointmentInfo 的定义,它位于不同的类中:
@interface AppointmentInfo : NSManagedObject
@property (nonatomic, retain) NSDate * aStartTime;
@property (nonatomic, retain) NSDate * aEndTime;
@property (nonatomic, retain) NSString * aServiceTech;
@property (nonatomic, retain) NSString * aApptKey;
@property (nonatomic, retain) NSDate *aShortDate;
不知何故,我需要获取返回数组中的数据并将其放在 AppointmentInfo 中。我已经尝试了各种排列,查看了谷歌和 SO,但我找不到任何东西。我难住了!我该怎么做?