A singleton class returns the same instance no matter how many times an application requests it. 单例设计每次只会返回相同的实例;A typical class permits callers to create as many instances of the class as they want, 请求者可以创建很多的实例只要他们想的话;whereas with a singleton class, there can be only one instance of the class per process. A singleton object provides a global point of access to the resources of its class. Singletons are used in situations where this single point of control is desirable, such as with classes that offer some general service or resource.
You obtain the global instance from a singleton class through a factory method. The class lazily creates its sole instance the first time it is requested and thereafter ensures that no other instance can be created. A singleton class also prevents callers from copying, retaining, or releasing the instance. 单例类不允许用户去进行修改拷贝等操作;You may create your own singleton classes if you find the need for them.你可以自己去创建你认为有必要的单例类; For example, if you have a class that provides sounds to other objects in an application, you might make it a singleton.
Several Cocoa framework classes are singletons. They include NSFileManager, NSWorkspace, and, in UIKit, UIApplication and UIAccelerometer. The name of the factory method returning the singleton instance has, by convention, the form sharedClassType. Examples from the Cocoa frameworks are sharedFileManager, sharedColorPanel, and sharedWorkspace.