我正在开发应用程序并简单地编辑单元格文本字段并完成编辑,我正在尝试更新核心数据,但应用程序获取堆栈,有时它会给出 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();
}
}
}
}
}