Using formatters in cappuccino from Xcode
Posted: 2011-07-29
Updated: 2011-07-29
At the time of this writing, cappuccino does not support NSDateFormatter (or any other formatter) if you drag it directly in Xcode.
If you want to use a formatter in Xcode/IB (and you will want), the easiest way is to drag a regular object (the blue cube) then create a class that inherit from CPFormatter, like so:
1 @implementation DateFormatter:CPFormatter
2
3 - (CPString)stringForObjectValue:(id)anObject
4 {
5 return [anObject dateString]; // dateString is a method in my Date category that format it like I want
6 }
7
8 @end
Then bind your object (mostly textField) to the blue cube and you are done.
I made a screencast explaining the procedure. It's a bit cropped and not really good because I made it in a hurry.
Downloads: H264, WebM, Ogg Theora.