Objective c 使用MagicalRecord,如何将数据从NSArray中取出并放入NSManagedObject?

Objective c 使用MagicalRecord,如何将数据从NSArray中取出并放入NSManagedObject?,objective-c,core-data,magicalrecord,Objective C,Core Data,Magicalrecord,我正在使用MagicalRecord处理核心数据对象。我在使用MR放入的NSArray检索核心数据对象时遇到问题。。。我似乎无法将数据从阵列中取出并放入NSManagedObject,以便处理它。这是我的密码: // create the predicate NSArray *apptDataArray = [NSMutableArray new]; NSPredicate *predicate = ([NSPredicate predicateWithFor

我正在使用MagicalRecord处理核心数据对象。我在使用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中。我尝试过各种排列,在谷歌上搜索过,但什么都找不到。我被难住了!我怎么做?

我不确定我是否正确理解了您的问题,但是 fetch请求的结果
apptDataArray
只是
AppointmentInfo
对象的数组,因此您可以使用

AppointmentInfo *appt = [apptDataArray objectAtIndex:i]; // 0 <= i < apptDataArray.count

失败的具体症状是什么?这不是失败。。。我只是不知道如何将从MR返回的NSArray数据获取到AppointmentInfo中,以便获取单独的字段(即aStartTime、aEndTime)并使用它们。
AppointmentInfo *appt = [apptDataArray objectAtIndex:i]; // 0 <= i < apptDataArray.count
for (AppointmentInfo *appt in apptDataArray) {
    NSLog(@"startTime=%@, endTime=%@", appt.aStartTime, appt.aEndTime);
}