TeaCupApp
TeaCupApp

Reputation: 11452

Xcode couldn't find NSObject's method - Objective C

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

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/Reference/Reference.html#//apple_ref/occ/instm/NSObject/className

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

Answers (2)

saadnib
saadnib

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

omz
omz

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

Related Questions