我遇到了这个错误
Incompatible integer to pointer conversion assigning to NSString from int
但我不理解以下代码的概念:
int counts;
counts = self.notificationarray.count;
title.text = (@"Notifications %i", counts );
最佳答案
替换:
title.text = (@"Notifications %i", counts );
与:
title.text = [NSString stringWithFormat:@"Notifications %i", counts];
因为您当前拥有的代码根本没有执行您想要的操作。我猜它正在为标题文本分配一个字符串(@"Notifications %i"
),然后尝试接下来分配一个整数(counts
)。您想要做的是创建一个具有格式的字符串并将其设置为标题文本。
关于ios - 整数到指针的转换不兼容。 iOS, objective-c ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22465565/