[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {
Course *course = [Course MR_createInContext:localContext];
course.classesName = classesName;
course.teacherName = teacherName;
course.classroom = @"体育馆";
course.startTime = startTime;
course.weekday = weekday;
course.weekNumber = [NSKeyedArchiver archivedDataWithRootObject:allweekNumber];
course.howLong = howLong;
} completion:^(BOOL success, NSError *error) {
NSLog(@"SUCCESS: %d, with ERROR: %@", success, error);
}];
这里是代码,里面NSKeyedArchiver那行感觉有问题,因为数据肯定都对,但是存的时候有时候存不上会在这句崩溃,有的时候是能存上,但是读不出来。求教各位
1
DavidHu OP 会报一个EXC_BAD_ACCESS(code:1 ....的错
|