我想将 uiviewcontroller 类保存到 coredata 中,然后单击按钮从 coredata 中检索它。我已经用 nsarchiver 和 nsunarchiver 试过了。将类转换为 nsdata 并保存到 coredata。但在检索时出现错误:
-[__NSArrayI 字节]:无法识别的选择器发送到实例 0x6d442a0 我的代码如下
// the button press for saving the object
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:viewcontrollerobject];
ViewData *viewdetails=[NSEntityDescription insertNewObjectForEntityForName:@"ViewData" inManagedObjectContext:[self managedObjectContext]];
viewdetails.view = data;
viewdetails.order = [NSNumber numberWithInt:1];
[self.fetchedResultsController performFetch:nil];
//button press for retrieving the class
[self.fetchedResultsController performFetch:nil];
NSData *theData;
theData = [fetchedResultsController.fetchedObjects valueForKey:@"view"];
viewcontroller *newviewcontrollerobject;
newviewcontrollerobject=[NSKeyedUnarchiver unarchiveObjectWithData:theData];
[newviewcontrollerobject.view setFrame:CGRectMake(200, 200, 300, 150)];
[self.view addSubview:newviewcontrollerobject.view];
请帮我更正这段代码