我真的疯了这六行代码。用UITextField疯狂
注:nome
和prezzo
2个文本框
NSString *itemName = (NSString *) [rowVals objectForKey:@"name"];
NSString *itemPrice = (NSString *) [rowVals objectForKey:@"price"];
nome.text = itemName;
nome.userInteractionEnabled = YES;
prezzo.text = itemPrice;
prezzo.userInteractionEnabled = YES;
不知道为什么,当itemPrice
这些标签的一个复制,该程序在SIGABRT去。 相反,如果我尝试使用NSLog(@"%@",itemPrice);
读取内容,它会返回确切的值,所以这意味着这是一个有效的NSString
。
我发现的唯一的解决方案是通过一个NSNumber
:
NSNumber *itemPrice = (NSNumber *) [rowVals objectForKey:@"price"];
prezzo.text = [[NSString alloc] initWithFormat:@"%@", itemPrice];
还有另一种方式直接使用NSString
?
权!我没有检查。谢谢。 – Oiproks