Monday, July 5, 2010

How to get the class of an object.

Use this to:
  • determine if the object is a instance of a NSNumber or other Class
  • if the object is nil or if it's a NSNumber or other Class
if ([obj class] == [NSNumber class])

or use this to determine if the object is a kind of class
if ([obj isKindOfClass:[NSNumber class]])

2 comments:

  1. you forgot a = in the first comparison (should be == ) right?

    ReplyDelete
  2. Thanks Pierre. updated the post.

    ReplyDelete