簡體   English   中英

錯誤:由於未捕獲的異常'NSInvalidArgumentException'而終止應用程序,原因:' - [NSCFNumber isEqualToString:]:

[英]Error:Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFNumber isEqualToString:]:

在我的應用程序中,我將Amount字段的值輸入到textfield中,該字段的數據類型為float,然后將其插入到數據庫中。當我運行我的應用程序時,它會出現以下錯誤。

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];

您正在嘗試將Number設置為標簽的文本。 標簽文本must是字符串。 所以你需要先將Number值轉換為NSString ...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM