content top

Objective-C: Showing meaningful error alerts

A very trivial, yet often overlooked property of NSError is the localizedDescription and localizedRecoverySuggestion property. Most Objective-C frameworks whether Apple’s own SDK or third party frameworks use a NSError out reference to communicate errors to the caller. To give you an example, take the NSJSONSerialization class. Parsing JSON from a data (say response data from a NSURLConnection) can fail if the JSON is malformed. id...

Read More

iOS Tip: Informing the user of your intent to use their location

iOS Tip: Informing the user of your intent to use their location

If you ever use location services in your app, consider using CLLocationManager’s purpose text field to set a string that says why exactly your app requires location information. This goes a long way in convincing the user as to why they need to provide you with their location information. The image below shows a blank location request alert. When you set the CLLocationManager’s purpose property, self.locationManager =...

Read More

Panacea for slow Xcode

Wrote a quick and dirty script for clearing “nonsense” files with a click. Copy the contents of this script to a file on your Mac. Save it to a file named, say, cleanup.sh, preferably in your home directory (or the directory where your terminal opens up by default) Set execute permissions to it by typing, chmod +x cleanup.sh You are done. Whenever Xcode “misbehaves”, just execute this script. It cleans up your...

Read More

Adding Twitter support (iOS 5 with oAuth fallback) to your iOS App with RSOAuthEngine

Adding Twitter support (iOS 5 with oAuth fallback) to your iOS App with RSOAuthEngine

Till today, the two most commonly used ways (without writing tediously long code) to integrate Twitter connect to your app is Ben Gottlieb’s Twitter OAuth library By using ShareKit The only problem I have with both these libraries is that, they are bloated. You end up adding at least 20 classes (more than 50 files in the first case and even more if you go with ShareKit). Call me a person with Not Invented Here syndrome, but I hate...

Read More

ARC retain cycles and blocks

I wrote a method to add blocks based completion handler support to AVAudioPlayer. The calling code looks like this. __block MKAudioPlayer *player = [[MKAudioPlayer alloc] initWithResourceName:@"Test.mp3"]; [player playWithCompletionHandler:^{ player = nil; }];__block MKAudioPlayer *player = [[MKAudioPlayer alloc] initWithResourceName:@"Test.mp3"]; [player...

Read More

iOS Tutorial: Image Cache and Loading Thumbnails using MKNetworkKit

iOS Tutorial: Image Cache and Loading Thumbnails using MKNetworkKit

If you have been following me on Twitter or reading MKBlog, you would already be knowing about MKNetworkKit. I wrote a introductory post on MKNetworkKit couple of months ago and later explained in a more detailed post on how to use it in other sophisticated scenarios. Contents Step 1: Create a Flickr Engine Step 2: Create a custom cache directory for storing the cached Flickr thumbanils Step 3: Write a...

Read More
Page 2 of 912345...Last »
content top