get type of NSNumber

Posted by okami on Stack Overflow See other posts from Stack Overflow or by okami
Published on 2010-03-25T19:34:45Z Indexed on 2010/03/25 19:43 UTC
Read the original article Hit count: 512

Filed under:
|

I want to get the type of NSNumber instance.

I found out on http://www.cocoadev.com/index.pl?NSNumber this:

 NSNumber *myNum = [[NSNumber alloc] initWithBool:TRUE];

 if ([[myNum className] isEqualToString:@"NSCFNumber"]) {
  // process NSNumber as integer
 } else if  ([[myNum className] isEqualToString:@"NSCFBoolean"]) {
  // process NSNumber as boolean
 }

Ok, but this doesn't work, the [myNum className] isn't recognized by the compiler. I'm compiling for iPhone.

© Stack Overflow or respective owner

Related posts about nsnumber

Related posts about objective-c