Reputation: 11452
I got into a weird situation, I am trying different methods of NSObject just to know how it works. I am currently testing them on a simple view based application on iOS. I created a random object greater which returns objects in id as basic NSObject, Than I want to determine what object it is by getting their class name. Therefore I used below method...
Link Edited
Now when I call this method on my random object, Like...
[object className];
Xcode gives me an error saying this...
Instance method '-className' not found
Is this method deprecated? Or Am I doing something wrong?
Thanks
Upvotes: 1
Views: 1045
Reputation: 11145
If you look at the documentation it say's that it only available in Mac OS X.
className
Returns a string containing the name of the class.
- (NSString *)className
Return Value
A string containing the name of the class.
Discussion
This method is invoked by Cocoa’s scripting support classes.
Availability
Available in Mac OS X v10.0 and later.
What is your purpose of finding class name.
Upvotes: 2
Reputation: 53561
For whatever reason, the className
method only exists on Mac OS X. On iOS you can use NSStringFromClass([object class])
instead.
Upvotes: 7