bdunagan

bdunagan

February 19 2010
Cocoa Tip: Continuous Updates and Bindings

Today, I was looking at a UI bug where the value of an NSTextField, populated through Cocoa Bindings, wasn’t getting saved. I tabbed over to the field, changed the value, tabbed over to the blue “Done” button and hit Space. Value saved. No bug. So I tried following the steps to reproduce exactly. Click in the field; change the value; click “Done”. Ah, the value didn’t save. Turns out, bindings don’t fire by default for an NSTextField unless it loses focus. To get the bindings to fire, I had to go into Interface Builder and check “Continuously Updates Value” (see the screenshot). With that checked, the bindings fired for both NSControlTextDidEndEditingNotification and NSControlTextDidChangeNotification notifications.

iPhone Tip: Rotating UIView Cocoa Tip: NSApp's currentEvent
LinkedIn GitHub Email