Take the 2-minute tour ×

Which class is Abstract class in Objective-C, I have read some doc where NSObject is Abstract class, but we can create instance of NSObject, then how it is follow the abstract class rule.

NSObject *obj = [[NSObject alloc] init];    
NSLog(@"description = %@",[obj description]);    
NSLog(@"class name = %@",[obj class]); 

Please advice.

And also I heard another one Abstract Class in Objective-C, what is the name of the class?

share|improve this question

2 Answers 2

Objective-C has no compile time restraint against instantiating abstract classes. See Creating an abstract class in Objective C

share|improve this answer

In Objective-C there is no language level concept of an abstract class. You have to read the documentation for a class to find out if it should be treated as an abstract class. There are a few such classes in Cocoa, e.g. NSObject, NSProxy and NSOperation. It's more common for behaviour to be defined in protocols rather than in abstract classes.

The Cocoa framework contains to root classes (i.e. class which do not have superclasses). NSObject is one root class and NSProxy is the other. NSProxy does not implement an init method which means an exception is raised when you attempt to create an instance.

share|improve this answer

Your Answer


