Iphone 信息:“[CFString retain]:发送到解除分配实例的消息…”是的,您的回答是正确的。数据显示在表视图中,并且我已在接收视图控制器中实现了NSFETCHEEDRESULTSCONTROLLER委托方法。您是否可以尝试\uuuuu bridge而不
Iphone 信息:“[CFString retain]:发送到解除分配实例的消息…”是的,您的回答是正确的。数据显示在表视图中,并且我已在接收视图控制器中实现了NSFETCHEEDRESULTSCONTROLLER委托方法。您是否可以尝试\uuuuu bridge而不,iphone,ios5,Iphone,Ios5,信息:“[CFString retain]:发送到解除分配实例的消息…”是的,您的回答是正确的。数据显示在表视图中,并且我已在接收视图控制器中实现了NSFETCHEEDRESULTSCONTROLLER委托方法。您是否可以尝试\uuuuu bridge而不是\uuuu bridge\uu transfer?看起来您的CFString对象发布得太快了。或者让它保持原样,不要发布uuiString,因为根据我对文档的理解,ARC正在为您这样做。谢谢!这就是问题所在。花时间回顾了“桥”和“桥”之间的区
信息:“[CFString retain]:发送到解除分配实例的消息…”是的,您的回答是正确的。数据显示在表视图中,并且我已在接收视图控制器中实现了NSFETCHEEDRESULTSCONTROLLER委托方法。您是否可以尝试
\uuuuu bridge
而不是\uuuu bridge\uu transfer
?看起来您的CFString对象发布得太快了。或者让它保持原样,不要发布uuiString
,因为根据我对文档的理解,ARC正在为您这样做。谢谢!这就是问题所在。花时间回顾了“桥”和“桥”之间的区别。
- (void)didCancelNewLoan:(Loan *)loan {
// save the context
NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];
[context deleteObject:loan]; // *** EXC_BAD_ACCESS here ***
// This method is called from a the following method in a second class:
- (IBAction)cancel:(id)sender {
[delegate didCancelNewLoan:self.loan];
}
// The loan ivar is created by the original class
// in the below prepare for Segue method:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"NewLoan"]) {
UINavigationController *navController = (UINavigationController *)[segue destinationViewController];
LoanViewController *loanView = (LoanViewController *)[[navController viewControllers] lastObject];
loanView.managedObjectContext = self.managedObjectContext;
loanView.delegate = self;
loanView.loan = [self createNewLoan];
loanView.newLoan = YES;
}
// Finally, the loan is created in the above
// method's [self createNewLoan] command:
- (NSManagedObject *)createNewLoan {
//create a new instance of the entity managed by the fetched results controller
NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];
NSEntityDescription *entity = [[self.fetchedResultsController fetchRequest] entity];
NSManagedObject *newManagedObject = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context];
[newManagedObject setValue:[NSDate date] forKey:@"timeStamp"];
CFUUIDRef uuid = CFUUIDCreate(NULL);
CFStringRef uuidstring = CFUUIDCreateString(NULL, uuid);
//NSString *identifierValue = (__bridge_transfer NSString *)uuidstring;
[newManagedObject setValue:(__bridge_transfer NSString *)uuidstring forKey:@"identifier"];
CFRelease(uuid);
CFRelease(uuidstring);
NSError *error;
[self.fetchedResultsController performFetch:&error];
NSLog(@"%i items in database", [[self.fetchedResultsController fetchedObjects] count]);
return newManagedObject;
}
assert( [ NSThread isMainThread ] ) ;
- (IBAction)cancel:(id)sender
{
NSError *error;
NSManagedObjectContext *context = [self.loan managedObjectContext];
[context deleteObject:self.loan];
if (![context save:&error])
NSLog (@"Error saving context: %@", error);
}
- (void)dealloc {
fetchedResultsController.delegate = nil;
}