This is a perfectly acceptable and thread-safe way to create an instance of your class. It may not technically be a “singleton” (in that there can only ever be 1 of these objects), but as long as you only use the [Foo sharedFoo]
method to access the object, this is good enough.
More Related Contents:
- Correct Singleton Pattern Objective C (iOS)?
- How do you trigger a block after a delay, like -performSelector:withObject:afterDelay:?
- Waiting until two async blocks are executed before starting another block
- Why does Apple recommend to use dispatch_once for implementing the singleton pattern under ARC?
- What’s the difference between synchronous and asynchronous calls in Objective-C, versus multi-threading?
- Workaround on the threads limit in Grand Central Dispatch?
- Does dispatch_async(dispatch_get_main_queue(), ^{…}); wait until done?
- How to asynchronously load an image in an UIImageView?
- Singleton in iOS Objective C doesn’t prevent more than one instance
- EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) on dispatch_semaphore_dispose
- How can I make a UITextField move up when the keyboard is present – on starting to edit?
- Creating a blurring overlay view
- Explaining difference between automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars, edgesForExtendedLayout in iOS7
- How to intercept touches events on a MKMapView or UIWebView objects?
- Always pass weak reference of self into block in ARC?
- Add views in UIStackView programmatically
- Can I use Objective-C blocks as properties?
- Create and export an animated gif via iOS?
- Passing parameters to addTarget:action:forControlEvents
- Importing Project-Swift.h into a Objective-C class…file not found
- Get System Volume iOS
- UIRefreshControl – beginRefreshing not working when UITableViewController is inside UINavigationController
- Programmatically scroll a UIScrollView
- How to enable back/left swipe gesture in UINavigationController after setting leftBarButtonItem?
- How to create border in UIButton?
- How to set the full width of separator in UITableView
- display done button on UIPickerview
- Block_release deallocating UI objects on a background thread
- Modal segue, navigation bar disappears
- How do I do weak linking in Swift?