I spent a few minutes today trying to figure out why, when setting a value to zero in an NSTableView, the number formatter I had associated with that column (to add a percentage sign to each number) was not being applied. Eventually, I realized that zero is a special case for NSNumberFormatter, and by default [...]
WILTAC #5: zero is a special case
December 9th, 2008 · No Comments
Tags: cocoa · macosx · Programming · wiltac
WILTAC #4: Undo
November 19th, 2008 · No Comments
Today I learned how to add support for undo/redo operations using NSUndoManager. This was completely new to me, and I was surprised at how cleverly done it is – essentially, for every operation that you want to undo, you provide the “inverse” operation, and NSUndoManager takes care of keeping them in appropriate stacks for undo/redo, [...]
Tags: cocoa · macosx · Programming · wiltac
WILTAC #3: NSZombieEnabled
October 17th, 2008 · 2 Comments
I learned today about the NSZombieEnabled environment variable (this is its correct name, and not NSZombiesEnabled as stated in Hillegass’ book). If you set it to YES, whenever you try to send a message to a deallocated object you will get a message like this in the console:
message sent to deallocated instance 0xe02b790
And the debugger [...]
Tags: cocoa · Programming · wiltac
WILTAC #2: Designated initializers
October 10th, 2008 · No Comments
I learned today the term designated initializer:
When a class has multiple initializers, the designated initializer is the one that actually does the work, normally the one with the most parameters. All other initializers call the designated one, providing different amounts of default parameter values.
I was aware of the concept – many classes have [...]
Tags: cocoa · macosx · objectivec · Programming · wiltac
WILTAC #1: invoking methods on nil in Objective-C
October 7th, 2008 · No Comments
Welcome to the first installment of “What I learned today about Cocoa” (WILTAC).
I have recently started reading Aaron Hillegass’ excellent Cocoa Programming for Mac OS X, third edition, with the intention of brushing up my very lacking Cocoa skills (all of them learned empirically by looking at other people’s code and reading the documentation). To [...]
Tags: cocoa · macosx · objectivec · Programming · wiltac