Podcast Idea

A podcast idea…

Introducing Merge Conflicts a Cocoa focused debate podcast where people argue for or against different systems / programming patterns. There is a central, ever repeating host who moderates the debate and two guests who argue for either side. Some show ideas include:

  • Core Data vs. Custom SQL
  • Storyboards vs. XIBs
  • Git vs. Mercurial
  • Homebrew vs. MacPorts
  • CocoaPods vs. Manual Code Sharing
  • AppCode vs. Xcode
  • Code generators (like mogenerator) Love Them vs Hate Them
  • TestFlight vs. HockeyApp
  • Kiwi vs. XCTests
  • Retain vs. Release
  • And so on…

Thoughts? Let me know via email or the twitters @zorn.

IBOutletCollection

Did a short show and tell at the last CocoaHeads meeting demoing something I learned at work and hadn’t known about before, that being IBOutletCollections.

For seasoned Cocoa developers we all know that an IBAction is typically how a button sends a message to the controller that something should happen. On the flip side there is IBOutlet which is a pointer to a view in the UI that let’s the controller have access, typically to update the view’s contents or attributes.

Well an IBOutletCollection lets you have access to a whole collection of views via a single connection. In code declaring an IBOutletCollection is going to look something like this:

@property (strong, nonatomic) IBOutletCollection(UITextField) NSSet *textFields;

When you declare the type of the outlet you can be specific such as UITextField or use higher level classes like UIView and connect to many different kinds of views. Technically you can use NSArray but since the order isn’t something I think is guaranteed best to stick to NSSet. Finally, while most outlets should be using weak references, these use strong since the view controller needs to own the array that contains the connections.

When you want to iterate over the collection just use fast enumeration like you normally would with an NSSet.

- (void)updateUI
{
    for (UITextField *textField in self.textFields) {
        textField.text = self.mainTextField.text;
        if (self.isBlue) {
            textField.textColor = self.view.window.tintColor;
        } else {
            textField.textColor = [UIColor redColor];
        }
    }
}

For a simple project demo see my OutletDemo project on GitHub.

Some real world use cases for IBOutletCollection might include theming (outlet collections for various styles, then making connections to view that should be styled) as well as form access and validation. IBOutletCollection was introduced in iOS 4 so theres no reason not to check it out. Enjoy.

Updating Homebrew’s “httpListenAddress” Default for Jenkins

I’ve setup some Jenkins servers in the past for Ruby on Rails apps but these days we are trying to get things running for iOS deployment and testing at work.

To experiment with some plugins and such I have my own Mac mini and installed Jenkins via Homebrew. Overall it’s working great though I was a bit stumped as to why I couldn’t load the Jenkins webpages outside of using localhost:8080 on the Mac mini itself. Worked fine last I did a clean install.

Turns out the Launch Agent settings Homebrew gives you (located at ~/Library/LaunchAgents/homebrew.mxcl.jenkins.plist for me) will launch with the following command line parameter --httpListenAddress=127.0.0.1. Edit this to 0.0.0.0 (the default) to allow all addresses.

I know this isn’t the most enjoyable blog post but wanted to post it as Google Food for others who might run into the issue.

Other related posts: