开发者

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

In my app i entered the value of Amount field into textfield and the datatype of that field is float and then insert it into database.when i run my app it gives following error.

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

here is my code to insert data:

 NSString *amt=txtTotalBill.text;
float amount = [amt floatValue];


NSString *insertData=[NSString stringWithFormat:@"insert into tbl_Bills(Amount) values ('%f')",amount];
开发者_开发百科

and the app gives error at this point:

  [label3 setText:[[BillTableArray objectAtIndex:indexPath.row]objectForKey:@"Amount"]];


The object returned by [[BillTableArray objectAtIndex:indexPath.row]objectForKey:@"Amount"] is not a NSString.

NSString *string = [NSString stringWithFormat:@"%@", [[BillTableArray objectAtIndex:indexPath.row]objectForKey:@"Amount"]];

[label3 setText:string];


you are trying to set Number as label's text. Where label text must be a string. So you need to first convert Number value into NSString...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜