ARC 中不允许从 NSInteger 到 NSString 的隐式转换。应该使用什么解决方法来处理整数
这是我在 viewcontroller.m 文件中的代码,
- (void)viewDidLoad{
[super viewDidLoad];
[self.abilitygeneration setText:((TestAbility *)[self.testabilities objectAtIndex:0]).abilitygeneration]; }
它给了我一个错误:ARC 不允许将 NSInteger 又名 int 隐式转换为 NSString。如何启用 ARC 并找到解决方法。除了 setText,我可以使用什么?
ability Generation 在 TestAbility.h 文件中设置为 NSInteger ..谢谢
This is my code in my viewcontroller.m file
- (void)viewDidLoad{
[super viewDidLoad];
[self.abilitygeneration setText:((TestAbility *)[self.testabilities objectAtIndex:0]).abilitygeneration]; }
It gives me an error implicit conversion of NSInteger aka int to NSString is disallowed with ARC. How do I enable ARC and have a workaround for this.Instead of setText what can I use?
abilitygeneration is set as NSInteger in TestAbility.h file.. thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,如果我理解正确的话,
setText:
接受一个NSString
而你有一个NSInteger
?如果这是正确的,您可以按如下方式显式转换它们:So if I've understood correctly,
setText:
takes anNSString
and you have anNSInteger
? If that's correct you can explicitly convert them as follows: