基本上我有这样的代码:
l11 = [NSString stringWithFormat: @"Health: %@", chealth, @"Ammo: %@", cammo]; 其中l11是一个NSString,我希望它等于“健康”+“双倍健康”+“弹药:”+双倍。
现在,它工作得很好,但它显示null,而双精度值应该是null,即使它们被声明了,我测试了这一点。如何解决这个问题?
发布于 2011-04-23 19:41:44
试试这个,假设chealth和cammo的类型是double:
l11 = [NSString stringWithFormat: @"Health: %f Ammo: %f", chealth, cammo];发布于 2011-04-23 19:48:25
您正在尝试将double (%f)格式化为对象(%@)。阅读String Format Specifiers。
https://stackoverflow.com/questions/5763915
复制相似问题