Skip to content

Comment on Your First MacRuby App in 4 Stepsparent

Comments

You mean the connections? Yeah, that was the most difficult thing to wrap my head around when I first started learning iOS programming.

Apple's frameworks are strongly MVC out of the box, but unlike some other frameworks, it doesn't automatically "wire up" the view and the view controller for you automatically. In the MS world, you double click on a button and an OnClick handler is created for you in the code behind class. Views and their view controller classes are strongly coupled. In the Apple world, views and controllers are very separate things. There's a huge wall between them and it's up to the controller to inform the view of its properties and actions. This is different from other frameworks where it goes in the other direction: the controller loads a view and queries the view for its elements (e.g, Android).

So in your NIB/XIB file, once you've assigned a view controller class for your view, you have to manually associate elements in the view to the appropriate properties and actions in the controller. That's what the connections are. No magic. Just very loose coupling and I think the "connect the dots" UI helps to illustrate that.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.