在我的应用程序中,我将金额字段的值输入到文本字段中,该字段的数据类型为浮点型,然后将其插入到数据库中。当我运行我的应用程序时,出现以下错误。
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFNumber isEqualToString:]:
这是我插入数据的代码:
NSString *amt=txtTotalBill.text;
float amount = [amt floatValue];
NSString *insertData=[NSString stringWithFormat:@"insert into tbl_Bills(Amount) values ('%f')",amount];
此时应用给出错误:
[label3 setText:[[BillTableArray objectAtIndex:indexPath.row]objectForKey:@"Amount"]];
最佳答案
[[BillTableArray objectAtIndex:indexPath.row]objectForKey:@"Amount"]
返回的对象不是 NSString
。
NSString *string = [NSString stringWithFormat:@"%@", [[BillTableArray objectAtIndex:indexPath.row]objectForKey:@"Amount"]];
[label3 setText:string];
关于iphone - 错误 :Terminating app due to uncaught exception 'NSInvalidArgumentException' , 原因:'-[NSCFNumber isEqualToString:]:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7307881/