1

I'm trying to get a value from a NSTextField (Label) and convert it to a int...

 minFormatter = [[NSNumberFormatter alloc] init];
  [minFormatter setNumberStyle:NSNumberFormatterNoStyle];
  NSNumber *minTimeValue = [minFormatter numberFromString:[NSString stringWithFormat:@"%@", [self.minTextLabel stringValue]]];
  [minFormatter release];
  int minTimeValueInt;
  minTimeValueInt = [minTimeValue intValue];
  NSLog(@"%@", minTimeValueInt);

I can't find anything wrong with it, but the NSLog returns (null) when I log the minTimeValueInt what's wrong?

1 Answer 1

3

%@ is the format string for an object. It's interpreting minTimeValueInt as a pointer, which is apparently 0 (null). Use %d instead.

Sign up to request clarification or add additional context in comments.

1 Comment

"00" still parses to the integer 0, which is equivalent (in this architecture) to null.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.