Dev*_*per 3 iphone objective-c
在我的应用程序中,我将Amount字段的值输入到textfield中,该字段的数据类型为float,然后将其插入到数据库中.当我运行我的应用程序时,它会出现以下错误.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFNumber isEqualToString:]:
Run Code Online (Sandbox Code Playgroud)
这是我插入数据的代码:
NSString *amt=txtTotalBill.text;
float amount = [amt floatValue];
NSString *insertData=[NSString stringWithFormat:@"insert into tbl_Bills(Amount) values ('%f')",amount];
Run Code Online (Sandbox Code Playgroud)
并且应用程序在此时给出了错误:
[label3 setText:[[BillTableArray objectAtIndex:indexPath.row]objectForKey:@"Amount"]];
Run Code Online (Sandbox Code Playgroud)
返回的对象[[BillTableArray objectAtIndex:indexPath.row]objectForKey:@"Amount"]不是NSString.
NSString *string = [NSString stringWithFormat:@"%@", [[BillTableArray objectAtIndex:indexPath.row]objectForKey:@"Amount"]];
[label3 setText:string];
Run Code Online (Sandbox Code Playgroud)