Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: Converting id to int

I have troubles converting id of an object to int (or NSINteger), so that I can use it in a loop later.

Here is the case:

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

But it results in:

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.

Thanks a lot!

like image 298
cell Avatar asked Aug 12 '13 09:08

cell


1 Answers

int taskNo = (int)[tasks indexOfObject:@"something"];
like image 83
iphonic Avatar answered Sep 29 '22 11:09

iphonic