IOS: converting id to int

I am having problems converting the id of an object to int (or NSINteger) so that I can use it in a loop later.

Like this:

// "tasks" is a mutable array int taskNo = [[tasks indexOfObject:@"something"] integerValue]; 

But this leads to:

 Bad receiver type 'NSUInteger' (aka 'unsigned int') 

I found a similar thread with code similar to what I had above, but unfortunately this did not work for me. I guess I should miss something simple.

Thank you so much!

+8
casting ios type-conversion
source share
1 answer
 int taskNo = (int)[tasks indexOfObject:@"something"]; 
+14
source share

All Articles