Articles for May 2008
Cocoa Bindings
Bindings use KVO to join UI widgets to data directly. Our example from the KVC article, with sliders changing colour components, can actually be done with no code at all, by simply binding the sliders' values to the colour's components.
The UI widget classes declare their bindings, largely for the benefit of Interface Builder; pick any widget instance in IB, click on the Bindings tab of the object inspector, and you'll see them listed. Each one typically represents one piece of the instance's internal state — its colour, whether its enabled or visible, its font, selection state, etc — and, of course, its value.
Bonjour in Python: A Tip
In Python, it's very common to not worry too hard about memory management; it is, after all, a fully garbage-collected language, and PyObjC extends this to the Cocoa classes you create from Python. However, this can bite you when dealing with Bonjour. You may remember me mentioning Bonjour issues before, and this is closely-related.
When a service appears on your network, of a type you've told Bonjour that you care about, you receive a netServiceBrowser:didFindService:moreComing: message. On receiving this, there are two common patterns, depending on your application: one is to store the NSNetService that's passed in to you, probably in a list which is the basis of a browser you're showing to the user. If the user selects the service, you resolve it.