iPhone: Get the class name of an object
Sometimes you want to know what type of object something is, when pulling it out of an array. In Obj-c there's a simple way to do that:
NSLog(@"object type = %@", [[myObject class] className]);
or
NSLog(@"object type = %@", [[myObject class] description]);
or!
if( [[myArray objectAtIndex:i] isKindOfClass:NSClassFromString(@"MyCustomClass")] ) { NSLog(@"it's a MyCustomClass"); }
UI Hacker - Code for Fun: iPhone: Get the class name of an object: "Sometimes you want to know what type of object something is, when pulling it out of an array. In Obj-c there's a simple way to do that: NS..."
No comments:
Post a Comment