Using UIPageControl as a container UIViewController

Using a UIPageControl to navigate though a series of UIView (or UIViewControllers) I would imagine is a fairly common task. However, there is now Apple provided way of doing this with out writing some code.
Continue reading ‘Using UIPageControl as a container UIViewController’ »

Useful Macros for UnitTests in Xcode

Unit testing is pretty simple within Xcode, especially since Xcode 4 started including ocunit. There are still a few things I come across which have taken some time for me to get around, to be able to test certain classes.
Most of the below has been found else where on the internet, I can’t remember where, since I have been using it foe some time. But I just bought it may be useful to consolidate this information into one place.
Continue reading ‘Useful Macros for UnitTests in Xcode’ »

NSPredicate predicateWithBlock & bindings

Since Mac 10.6 and iOS 4.0 NSPredicate has supported a method predicateWithBlock. I looks to be a pretty commonly used method, but I could find no examples and only limited documentation on the bindings dictionary argument to the block method.

+ (NSPredicate *)predicateWithBlock:(BOOL (^)(id evaluatedObject, NSDictionary *bindings))block

Continue reading ‘NSPredicate predicateWithBlock & bindings’ »

UITableView Place-holder image

The question of how to add a place holder view to an empty UITableView seems to be very common. There also seem to be many different solutions.
These place-holder views can be seem in a range of applications including the iOS AppStore when it doesn’t have a data connection.

Continue reading ‘UITableView Place-holder image’ »

UIPickerView as a keyboard view for UITableViewCell

It seems to be a common question on how to create custom a keyboard, or use a UIDatePicker or UIPickerView as the input.
Apple have an example on their website which works well. However this doesn’t work well when you cater for device rotation, everything rotates except for the keyboard.

Continue reading ‘UIPickerView as a keyboard view for UITableViewCell’ »

Simple block extension for UIAlertView

This is a very simple category for the UIAlertView class in iOS. I have always found it slightly frustrating that separate delegate methods are required for a simple Yes/No or OK/Cancel alert view, and that it is the same delegate method for which ever UIAlertView is responding – so you have to keep track of your alert view to know how to deal with the response.

In this post I’m going to show you how I created a category on UIAlertView to simplify the interface.

Continue reading ‘Simple block extension for UIAlertView’ »

NSOrderedSet and NSArrayController bindings

Since the introduction of Mac OS X Lion we have been give a new container which can be used for maintaining order in CoreData relationships – NSOrderedSet
One of the first issues I came across with this is that it isn’t bindings compatible with NSArrayController like NSSet and NSArray are. So I spent a while investigating how to work around this issue.
Continue reading ‘NSOrderedSet and NSArrayController bindings’ »

Resolving CoreData Validation Errors

With the default CoreData application delegate code provided by Apple, there isn’t much to go on when your CoreData object graph fails the validation check.

It is pretty simple to enhance the error logging to display the NSManagedObjects an entity/relationship which is causing the validation error.
Continue reading ‘Resolving CoreData Validation Errors’ »

NSTokenField, CoreData and Auto-completion

At first I had a few problems getting NSTokenField to work exactly as I wanted it to. What I was after was to create a one-to-many relationship between two CoreData entities.
For example, if I had a pre-existing list Contact entities, and I create and Invitation entity. I would want to link many contacts with this invitation.

Entity Layout
Continue reading ‘NSTokenField, CoreData and Auto-completion’ »

Adding instance variables to Obj-C categories

Categories are a great way of adding extra functionality to a Objective-C class. However (up until now!) you cannot extent the class by adding instance variables. Associative References were added to the Objective-C runtime in OS X 10.6 and iOS 3.1. This basically mean that every object contains a dictionary where you can store arbitrary key/value pairs.
Continue reading ‘Adding instance variables to Obj-C categories’ »