我工作的应用程序,只需编辑单元格文本字段,并在完成编辑,我试图更新coredata但应用得到堆栈以及一些时间给它SIGSTOP和某个时候说无法分配更多的内存有点错误,请帮助我。核心数据的更新会导致崩溃
- (void)textFieldDidEndEditing:(UITextField *)textField
{
if ((textField.tag - 999) > 0) {
NSArray *visible = [self.productTable indexPathsForVisibleRows];
UITableViewCell* cell = [self.productTable cellForRowAtIndexPath:[visible objectAtIndex:(textField.tag - 999)]];
for (UIView* subview in [cell.contentView subviews]) {
if ([subview isKindOfClass:[UITextField class]]) {
textField = (UITextField*)subview;
Product* myProduct = (Product*)[self.productArray objectAtIndex:(textField.tag - 1000)];
[myProduct setValue:[NSNumber numberWithFloat:[textField.text floatValue]] forKey:@"quantity"];
[myProduct setValue:[NSNumber numberWithFloat:[myProduct.quantity floatValue] * [myProduct.rate floatValue]] forKey:@"amount"];
NSLog(@"Product %@", myProduct);
NSError *error; if (![self.managedObjectContext save:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
}
}
}
}
任何人都可以帮助我呢? – Retro
http://grab.by/howq。 “ – Retro
”textField =(UITextField *)subview;“要覆盖委托的对象,尝试使用不同的指针(如*的UITextField = thisTextField(的UITextField *)子视图;) - 不知道如果是这样的问题(或者即使是故意的),但它是一个尝试。 – jimpic