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 covert an NSUInteger / NSInteger into an int value

Before the addition of 64bit in iOS it was possible to take an NSUInteger (or NSInteger) and put it into an int variable, like so: int arrayCount = [self.myArray count]; If you add 64bit support to your app you may notice a compiler warning when you do this: Implicit conversion loses integer precision: ‘NSInteger’ (aka […]

How to avoid WAL files in Core Data

Since iOS 7 and OS X 10.9 the default journalling mode in SQLite Stores is WAL. In addition to the main store file you’ll find a WAL file with the same (or larger) size as the store file, and a less important SHM file. Prior to this implementation it was easy to save the context, […]

How to delete a branch in Git

Sometimes Xcode gets confused with the intricacies of versioning. Frequently I find that I’m on a branch, everything is working fine, and for the life of me can’t merge it back into the Master branch. Often this happens because Xcode refuses NOT to make an change, such as update certain files I have already dealt […]

How to encode / convert a .strings file into UTF-16LE in Xcode

When you create a new .strings file in Xcode it will be encoded as Unicode UTF-8. That’s sufficient to hold all the special characters you can dream of. Some translation services such as ICanLocalize require .strings files to be submitted in UTF-16LE though. Puzzled about what this even means I found out that UTF-16LE can […]

How to encode / convert a .strings file into UTF-16LE in Xcode

When you create a new .strings file in Xcode it will be encoded as Unicode UTF-8. That’s sufficient to hold all the special characters you can dream of. Some translation services such as ICanLocalize require .strings files to be submitted in UTF-16LE though. Puzzled about what this even means I found out that UTF-16LE can […]

How to preload images in iOS

When you’re displaying a UIImage in your view controller it’s hardly noticeable how long it actually takes for the engine to “draw” the picture. Lenoard van Driel has tested this and confirms it takes 80ms – or in television terms, 2 frames. That’s something worth putting an audio delay in for. Drawing several images in […]

How to delete an NSManagedObject in Core Data

You can delete individual objects by using the NSManagedObjectContext method deleteObject, like so: [self.managedObjectContext deleteObject:yourManagedObject]; To delete all managed objects from your store, you can use a for-in loop: – (void)clearCoreData { NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@”YourEntity” inManagedObjectContext:self.managedObjectContext]; [fetchRequest setEntity:entity]; NSError *error = nil; NSArray *fetchedObjects = [self.managedObjectContext executeFetchRequest:fetchRequest […]

How to show SQLite Debug output from Core Data in iOS

Add this statement to your app’s Run Scheme -com.apple.CoreData.SQLDebug 1 and your Log Console shall be populated with fascinating statements such as 2013-11-20 18:49:53.715 YourApp[6245:70b] CoreData: annotation: Connecting to sqlite database file at “/Users/versluis/Library/Application Support/iPhone Simulator/7.1-64/Applications/1FED9364-3039-4D47-967E-9B075CBE8277/Documents/PatchBay.sqlstore” 2013-11-20 18:49:53.717 YourApp[6245:70b] CoreData: sql: pragma journal_mode=wal 2013-11-20 18:49:53.718 YourApp[6245:70b] CoreData: sql: pragma cache_size=200 2013-11-20 18:49:53.719 YourApp[6245:70b] CoreData: sql: […]