HOW CAN WE ACHIEVE SINGLETON PATTERN IN IOS?

Glen Martin

Total Post:4

Points:20
Posted by  Glen Martin
 524  View(s)
Ratings:
Rate this:
  1. Glen Martin

    Post:4

    Points:20
    How can we achieve singleton pattern in iOS?

    The Singleton design pattern ensures a class only has one instance, and provides a global point of access to it. The class keeps track of its sole instance and ensures that no other instance can be created. Singleton classes are appropriate for situations where it makes sense for a single object to provide access to a global resource. Several Cocoa framework classes are singletons. They include NSFileManager, NSWorkspace, NSApplication, and, in UIKit, UIApplication. A process is limited to one instance of these classes. When a client asks the class for an instance, it gets a shared instance, which is lazily created upon the first request.

      Modified On Aug-04-2015 11:13:25 PM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!