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

How to iterate for loop in reverse order in swift?

When I use the for loop in Playground, everything worked fine, until I changed the first parameter of for loop to be the highest value. (iterated in descending order) Is this a bug? Did any one else have it? for index in 510..509 { var a = 10 } The counter that displays the number […]

Custom views with Storyboard

In complex screens (View Controllers) I used to separate the whole thing in smaller pieces (I call them widgets). These widgets consist basically of a MyWidget.h and a MyWidget.m file as well as a MyWidget.xib file, where the root element is a UIView and the MyWidget class is the File Owner of the UIView. In […]

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 […]