iOS Development is easy with XCode, Swift3, UITableView, cocatouch, let's build iPhone, iPad and Macbook Applications.

Why does Apple recommend to use dispatch_once for implementing the singleton pattern under ARC?

What’s the exact reason for using dispatch_once in the shared instance accessor of a singleton under ARC? + (MyClass *)sharedInstance { // Static local predicate must be initialized to 0 static MyClass *sharedInstance = nil; static dispatch_once_t onceToken = 0; dispatch_once(&onceToken, ^{ sharedInstance = [[MyClass alloc] init]; // Do any other initialisation stuff here }); […]

How to open Settings programmatically like in Facebook app?

I need to open Settings programmatically from within my app. I searched across SO but everywhere people say that it’s impossible. But today I saw that it’s implemented in Facebook app. There’s a button on an UIAlertView and when you click it you open the Settings. So indeed this is possible to open Settings, I […]

Best way to sort an NSArray of NSDictionary objects?

I’m struggling with trying to sort an array of dictionaries. My dictionaries have a couple of values of interest, price, popularity etc. Any suggestions?

Arm64 architecture in xcode 5.1

In the new XCode 5.1, arm64 has become among the standard architectures to build for. However, in current projects of mine I included libraries (Google AdMob for example) that do not yet support this new architecture – these are now causing linker errors: ld: symbol(s) not found for architecture arm64 Google AdMob 6.8.0 for example […]

Objective C – calculating the number of days between two dates

Possible Duplicate: How can I compare two dates, return a number of days. I have two dates (as NSString in the form “yyyy-mm-dd”), for example: NSString *start = “2010-11-01”; NSString *end = “2010-12-01”; I’d like to implement: – (int)numberOfDaysBetween:(NSString *)startDate and:(NSString *)endDate { } Thanks!

How to register a custom app opening URL scheme with Xcode 4?

Xcode4 is asking for a huge number of arguments just to make this simple thing possible: NSString *stringURL = @”twitterriffic://”; NSURL *url = [NSURL URLWithString:stringURL]; [[UIApplication sharedApplication] openURL:url]; What are all these properties for? Why an image? Must I repeat the app identifier here? What role to choose if I want anyone to be able […]

IOS – How to segue programmatically using swift

I’m creating an app that uses the Facebook SDK to authenticate users. I’m trying to consolidate the facebook logic in a separate class. Here is the code (stripped for simplicity): import Foundation class FBManager { class func fbSessionStateChane(fbSession:FBSession!, fbSessionState:FBSessionState, error:NSError?){ //… handling all session states FBRequestConnection.startForMeWithCompletionHandler { (conn: FBRequestConnection!, result: AnyObject!, error: NSError!) -> Void […]

how to determine which apps are background and which app is foreground on iOS by application id

Using the method described in this question, I can get a list of apps running on an iOS device. I know PIDs and have access to their kinfo_proc structures. How can I determine which are foreground processes and which are background (assuming my app is background)? I tried to find this out base on information […]

Always pass weak reference of self into block in ARC?

I am a little confused about block usage in Objective-C. I currently use ARC and I have quite a lot of blocks in my app, currently always referring to self instead of its weak reference. May that be the cause of these blocks retaining self and keeping it from being dealloced ? The question is, […]

UILabel – string as text and links

I have a UILabel whose text I am getting from a server. Some of the text is to be identified as links, and on touching those links some action should be performed. e.g. NSString *str = @”My phone number is 645-345-2345 and my address is xyz”; This is the complete text for UILabel. I have […]