我工作的應用程序,只需編輯單元格文本字段,並在完成編輯,我試圖更新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