s.ross wrote:

How it's implemented now is that I have a separate controller for each field and the NSTextField delegates to that controller because for each character, I need to:

- dup-check and possibly count
- change a label to show the count and any dup alerts
- watch for control:completions:forPartialWordRange and provide a custom list

This seems like boneheaded code duplication, when what I really want is a more general class that can be told:

Hey! This NSTextField needs to be watched for dups, so split on [\s*,\s*] and each time a new word shows up, call my method:

theresANewWord:count withDuplicates:dups.

That suggests to me that subclassing NSTextField and allowing a single controller to register a callback would be the right way to go, but I'm struggling with how to specify *which* text field and whether my design idea is even sound.

Sounds to me like you need a small class hierarchy of delegate classes. Don't make each text-field point to a single controller. Assign each textfield a delegate object (instance of a specific delegate subclass) appropriate to the handling that field needs. The delegate objects may be coupled to the overarching controller for the "theresANewWord" functionality or the label-changing feature.

  -- GG

_______________________________________________

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