0
我有一個具有三個屬性的實體'testData':time,beat,rate。我需要每次遍歷'time'屬性,並將相應的節拍和速率值存儲在NSMutablearray中。遍歷iOS核心數據的單個實體
NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];
NSEntityDescription *entity = [[self.fetchedResultsController fetchRequest] entity];
NSManagedObject *newManagedObject = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context];
[newManagedObject setValue:[x] forKey:@"timeStamp"];
[newManagedObject setValue:[y] forKey:@"beat"];
[newManagedObject setValue:[z] forKey:@"rate"];
// Save the context.
NSError *error = nil;
if (![context save:&error]) {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
你是什麼意思MagicalRecord(一個開源庫「穿越時間屬性」?你的代碼是爲了創建一個新的實體,你的問題是關於獲取和解析現有的實體。你的問題是什麼? – Mundi