Thomas Schönfeld wrote:
Now I am wondering, because it seems to me the "example" is "wasting code". I used the "example", but the "extra" method setoutString is kinda useless. After a bit thinking I did this.... (see below). I didn't use the "extra" method and it works fine. So my question is, did I just do something not-Cocoa-like and am I still thinking to much C?

Well, I think the idea behind setOutString: is that it is an accessor, a central bottleneck through which all modifications to your text field go. So, it's simply the application of an object oriented programming technique. One could probably argue that it's a bit overkill for such a small example, but OTOH it's far from "a waste of code". Many projects start out as small one-offs, and exactly in cases like these it pays off to lightly over-engineer, because later you may realize you want a more complex control instead of a text field, and then you can simply replace one line of code in that accessor call, instead of having to change every occurrence of setIntValue: in four dozen call locations.

On 05.10.2008, at 07:54, Quincey Morris wrote:
It's worth noting that this whole approach (setting a field in the user interface), though not wrong, is rather un-Cocoa-like. It would be much more usual to define the count of characters as a numeric property (for example), and bind the text field to it, using a numeric formatter to format the number if you wished. But perhaps you are still a couple a chapters away from using bindings.


I wouldn't go so far as to call it "un-Cocoa-like". Bindings are a fairly new technology, and there are some complex considerations that make them hard for beginners to use correctly. Since this code was from a tutorial, I think it's a good thing they started with "the old way of doing things" first, particularly since I wouldn't want to have to tell a beginner about bindings-induced retain circles in their sample app.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to