[英]How to append a char to NSNumber in Objective-C?
我有一個來自API price: 10
的價格參數price: 10
我想在文本字段中顯示它,並在其后附加“ $”。 但這即使顯示也不會顯示我的電話號碼。 這是我的代碼:
cell.price.text = [[NSString stringWithFormat:@"%i",
(NSNumber*)DIC[@"items"][indexPath.row][@"price"]] stringByAppendingString:@" $"];
要打印NSNumber
您需要使用%@而不是%i
cell.price.text = [NSString stringWithFormat:@"%@ $",
(NSNumber*)DIC[@"items"][indexPath.row][@"price"]];
NSNumber
是一個對象,使用%i格式將無法正常工作。
cell.price.text = [NSString stringWithFormat:@"%@ $",
(NSNumber*)DIC[@"items"][indexPath.row][@"price"]];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.