NSDate question



I have been looking up the new classes presented in each chapter and it says that NSDate is a class cluster. What is a class cluster?



Class clusters are a little advanced for most readers, but here goes:

There are several subclasses of NSDate – when you think you are creating an NSDate, you might get an instance of any of those subclasses. (The subclasses are not advertised in the documentation or headers.) All you need to know is that the object you get back will respond to all the messages that an NSDate responds to. So, when you use the class NSDate, it doesn’t matter that it is a class cluster.

However, if you were ever to subclass NSDate, it would matter a lot. In general, you should be very reluctant to subclass from classes that are actually class clusters. These include: NSArray, NSString, NSDictionary, NSDate, NSNumber, NSData, and NSSet.

developer.apple.com/library/ios/ … uster.html