views:

200

answers:

1

I have a subclassed UIViewController that's acting as an ABPeoplePicker Navigation Controller Delegate. This view controller calls this ABPeoplePicker in a few different situations and the problem I'm having is figuring out which situation I'm responding to in

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person

UIAlertView has the tag property inherited from UIView to help sort this out but I can't find a similar property to use in ABPeoplePickerNavigationController. How are the Cocoa ninjas handling situations like this? Spin off custom delegates? Fiddle some BOOLs in the view controller subclass?

A: 

Basically, you have some state, and you're asking where it belongs, right? Unfortunately, the answer is "It really depends on the state."

If it's related to the operation of the view controller, I'd say stick it in there and keep the view controller as the delegate.

If it isn't really related and the whole delegate can be moved into a separate object, that may be in the end a lot cleaner. It's really easy to get nightmare controllers that are hundreds of lines long with dozens and dozens of methods. Splitting things up into multiple objects and using the composition pattern can be really helpful.

Colin Barrett