Objective-c – ObjectiveC Parse Integer from String

intiphoneobjective cstring

I'm trying to extract a string (which contains an integer) from an array and then use it as an int in a function. I'm trying to convert it to a int using intValue.

Here's the code I've been trying.

  NSArray *_returnedArguments = [serverOutput componentsSeparatedByString:@":"];
  [_appDelegate loggedIn:usernameField.text:passwordField.text:(int)[[_returnedArguments objectAtIndex:2] intValue]];

I get this error:

passing argument 3 of 'loggedIn:::' makes pointer from integer
without a cast

What's wrong?

Best Answer

I really don't know what was so hard about this question, but I managed to do it this way:

[myStringContainingInt intValue];

It should be noted that you can also do:

myStringContainingInt.intValue;