How to localise a string inside the iOS info.plist file?

You should use InfoPlist.strings file (keep both I & P capital) to localize values of Info.plist. To do this, go to File->New->File, choose Strings File under Resource tab of iOS, name it InfoPlist, and create. Open and insert the Info.plist values you want to localize like: NSLocationWhenInUseUsageDescription = “Description of this”; Now you can localize … Read more

Safe (bounds-checked) array lookup in Swift, through optional bindings?

Alex’s answer has good advice and solution for the question, however, I’ve happened to stumble on a nicer way of implementing this functionality: extension Collection { /// Returns the element at the specified index if it is within bounds, otherwise nil. subscript (safe index: Index) -> Element? { return indices.contains(index) ? self[index] : nil } … Read more

Emulating aspect-fit behaviour using AutoLayout constraints in Xcode 6

You’re not describing scale-to-fit; you’re describing aspect-fit. (I have edited your question in this regard.) The subview becomes as large as possible while maintaining its aspect ratio and fitting entirely inside its parent. Anyway, you can do this with auto layout. You can do it entirely in IB as of Xcode 5.1. Let’s start with … Read more

Can’t ignore UserInterfaceState.xcuserstate

Git is probably already tracking the file. From the gitignore docs: To stop tracking a file that is currently tracked, use git rm –cached. Use this, replacing [project] and [username] with your info: git rm –cached [project].xcodeproj/project.xcworkspace/xcuserdata/[username].xcuserdatad/UserInterfaceState.xcuserstate git commit -m “Removed file that shouldn’t be tracked” Alternatively you can use the -a option to git … Read more

How to create a delay in Swift?

Using a dispatch_after block is in most cases better than using sleep(time) as the thread on which the sleep is performed is blocked from doing other work. when using dispatch_after the thread which is worked on does not get blocked so it can do other work in the meantime. If you are working on the … Read more