iOS:将ID转换为int [英] iOS: Converting id to int
本文介绍了iOS:将ID转换为int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到了将对象的id转换为int(或NSINteger)的麻烦,所以我可以在稍后的循环中使用它。
I have troubles converting id of an object to int (or NSINteger), so that I can use it in a loop later.
/ p>
Here is the case:
// "tasks" is a mutable array
int taskNo = [[tasks indexOfObject:@"something"] integerValue];
但结果是:
Bad receiver type 'NSUInteger' (aka 'unsigned int')
我发现一个类似的线程与类似于我上面的代码,但不幸的是它不适合我。
I found a similar thread with code similar to what I have above, but unfortunately it didn't work for me. I guess I must be missing something simple.
推荐答案
int taskNo = (int)[tasks indexOfObject:@"something"];
这篇关于iOS:将ID转换为int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文