iOS Archives

These posts are syndicated from my iOS Dev Diary over at pinkstone.co.uk.

The format is slightly different with more code snippets and less explanations. I had originally designed it as a notebook in iOS Development – now you can follow along if you’re interested.

How to retrieve the current User Locale

The following method will return a two letter code of which language is set on the iOS device in question: NSString *myLanguage = [[NSLocale preferredLanguages] objectAtIndex:0]; There’s a list of language codes on Wikipedia: http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes Note that to compare the current value against a list of languages you support we need use the isEqualToString method. Here’s […]

How to localize your project in Xcode 4.4

Before we start we need to create a new file called Localizable.strings (from File – New – Resource – Strings File). Xcode needs one file per language. Next we create localized copies of our files: head over to your Project Editor (the big blue icon) select it again under Project (another blue icon) make sure […]

How to link to an iOS App

Direct web link to your app or developer account showing all your apps: http://itunes.com/apps/my-app-name http://itunes.com/apps/my-developer-name itms://itunes.com/apps/my-app-name (opens iTunes) itms://itunes.com/apps/my-developer-name (opens iTunes) itms-apps://itunes.com/apps/my-app-name (opens App Store) itms-apps://itunes.com/apps/my-developer-name (opens App Store) Direct link to a country specific app store (say Germany in this exampe): http://itunes.apple.com/de/app/my-app-name If your app name contains spaces replace them with dashes. Replace http […]

How to add version control to an existing project in Xcode

Setting up a local GIT repository: Open Terminal and change to the directory where your project is located (cd /path/to/your/project). Then use the following shell commands: git init git add . git commit -m “my initial commit (or any other comment you feel like)” NOTE: as of Mountain Lion you need to install the Xcode […]

How to style a table view header / footer

The UITableView implements a header and a footer when you’re using the tableView:titleForHeaderInSection method (tableView:titleForFooterInSection respectively). However when the header (or the footer) is displayed you can’t change the font or colour of your text. You can however implement the following methods in your table view delegate and create a custom UILabel object for the […]

How to add a background image to a table view

The easiest way to do this is by adding a UIImage to your table. Rather than instantiating a new table object you can simply add the following line into the first Table View Data Source method you have – such as this one: – (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { tableView.backgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@”background.jpg”]]; // Return the […]