Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
The primary function of a class object is to act as a factory object to create instances of the class. As we saw in the previous chapter, you create object instances by using the class method alloc. The next two sections cover areas where classes often define additional class methods. Convenience constructors and singletons are common patterns in the Cocoa frameworks and you may want to use them in some of your own classes.
Many of the Cocoa framework classes define convenience constructors, which combine allocation and initialization in a single method. The NSString class method string is a typical example. It returns an initialized, but empty string: