2012-07-11 45 views
1
-(void)dataManagerDidFinishLoading:(DataManager *)datamgr 
{ 
    NSLog(@"%@.....",datamgr); 

    pageArray=[datamgr.resultDataDictionary objectForKey:@"POS_GetPageResult"]; 
    GetPage *page=(GetPage *)[NSEntityDescription 
       insertNewObjectForEntityForName:@"GetPage" 
         inManagedObjectContext:managedObjectContext]; 

    NSError *error; 
    if (![managedObjectContext save:&error]) { 
     // This is a serious error saying the record could not be saved. 
     // Advise the user to restart the application 
     NSLog(@"Error........"); 
    } 

    [pageArray insertObject:page atIndex:0]; 
} 

回答

0

使用的NSKeyedArchiver:

NSData *data = [NSKeyedArchiver archivedDataWithRootObject:array]; 

注意,在阵列中的所有对象必须符合NSCoding协议。如果这些是自定义对象,那么这意味着您需要阅读Encoding and Decoding Objects。您可以将NSData作为BLOB存储在数据库中。希望这可以帮助你。

0

您可以使用可变形的核心数据类型。然后你的对象将被解析为一个id。请记住,可变形属性将传递给NSData对象(并反转)以存储(或检索)到核心数据中。