9

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!

cell
  • 119
  • 1
  • 1
  • 7

1 Answers1

15
int taskNo = (int)[tasks indexOfObject:@"something"];
iphonic
  • 12,615
  • 7
  • 60
  • 107