So, I’ve been watching the new Standford Coding Together series by Paul Hegarty and apparently I’ve been living under a rock because I completely missed the introduction of
IBOutletCollections in iOS 4 (mentioned in Lesson 3). These collections allow you to assign multiple objects to a single outlet, giving you an array of the objects in the storyboard.
@property (nonatomic, retain) IBOutletCollection(UISwitch) NSArray *switchCollection;
would allow you to connect multiple switches to the single
switchCollection outlet. Then you could use simple key/value coding to quickly toggle all the values:
[switchCollection setValue:@(NO) forKey:@"on"];
I’ve had a few projects where this would have come in handy and saved creating multiple outlets.