Subscribe to
NSLog(); Header Image


I continued working on the core UI for MailDrop 2.0 today. I added outlets to some more checkboxes and text fields and made them undoable. With a strong MVC background, "undo" is a fairly easy but - repeat after me - T E D I O U S task. I have about fourteen thousand lines of code (well, okay, about 500) of pure getter/setter/UI-updater code.

Because we want to be very, very AppleScriptable in the end, I'm clinging to MVC as if it was a hot babe and I was Rob Cesternino. What's funny is that I noticed that, upon entering a string in a text field, the following occurs:

  1. The action of a text field is setSomeValue: (generic name used here), a "setter" of sorts.
  2. A string comparison takes place so that you can't add infinite instances of the same string to the undo stack. This calls a value "get" accessor in the model to check the current string and compare it to the UI string (the one just entered).
  3. The setSomeValue: calls a setValue: method in my model.
  4. The model posts a notification to the window to update its UI.
  5. The window "updateUI" method calls the same value "get" method in the model to make sure it sets the text field to the proper value.

Overkill? Actually, no. Amusing? Undoubtedly. But again: T E D I O U S. 🙂

4 Responses to "Set/Get/Set/Get"

  1. Weekend Edition: WarCraft, Cocoa, Exams

    Today I played in the WarCraft 3 tournament. It was Humans & Orcs on Two Rivers, one of the new maps. I have to say I like the map, but it has some flaws. For one thing, it felt like...

  2. This is why people get into code generation 🙂

    Presumably you have some sort of object model that you are creating all your get/setters for? Could you describe that object model as an XML document? You could then run an XSLT transform to convert that into all your code. You could delgate most of the work to an abstract base class. It sounds like you may be kinda there, having setSomeValue call setValue with 'Some' as a method parameter?

  3. All of that work seems like more work than just copying/pasting similar chunks of code and changing a name or two here and there. I haven't got time to learn XSLT too.

  4. Like my other comment, this is the same answer: EOF. Makes all that stuff go away.

Trackback URI | Comments RSS

Leave a Reply to Erik J. Barzeski

