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 restore your iOS device with DFU / Recovery Mode

Sometimes iOS updates go awry. It may happen that the device hangs itself for good, refusing to activate or be recognised by iTunes. In that case, it’s time for a DFU reset, also known as Recovery Mode. Download an .ipsw file for your device from the Developer Centre (either a beta or the release version) […]

How to fix “property’s synthesized getter follows Cocoa naming convention for returning ‘owned’ objects”

Today Xcode surprised me with an error message I hadn’t heard before: property’s synthesized getter follows Cocoa naming convention for returning ‘owned’ objects. At first I thought, “isn’t that a good thing?”, and after checking how I had defined a new property I was clueless why this was happening: @property (nonatomic, strong) Phrase *newPhrase; What […]

How to add a custom initialiser to a Managed Object in Core Data

NSManagedObjects behave differently to NSObjects on many levels. If you’d like to add custom start-up behaviour in your NSManagedObjects, you’ll have noticed that overriding the standard init method isn’t working. Instead, we can use the awakeFromFetch method. This is called automatically when a managed object is retrieved from the Core Data stack: – (void)awakefrom { […]

How to use the iOS 5 Simulator in Xcode 5

If you’re running Mavericks then sadly the iOS 5 simulator is gone for good – both in Xcode 5 as well as Xcode 4.6.3. It appears that the Mavericks kernel is no longer compatible with iOS 5 any more, and we only have access to the iOS 6.0, 6.1, 7.0 and 7.1 simulators. To use […]

How to test for a (null) string in Objective C

I wanted to test if a string has a value when it’s returned from Core Data. So I thought, the right way to do this was to see if it’s equal to nothing, like so: if ([myString isEqualToString:@””]) { // should be empty… but may not be } But to my surprise this didn’t work […]

How to dismiss a Popover from the current UIViewController

Imagine you’re presenting a view controller in your storyboard via a Popover Segue: Simply drag from a button in your Main View Controller to your Other View Controller, and under segue select “Popover”. Works like a charm: the popover is presented, and if someone clicks outside the popover it is dismissed. Marvellous! Surely we should […]

How to create a custom UIPickerView

Creating picker views is similar to creating table views: you supply an array of data for each component by conforming to the UIPickerViewDataSource protocol. A component is equivalent to a section in a table view, and each component can have several sections. You can’t set much of this up in interface builder other than add […]