Question about cocoa delegate messaging
The "Add" button is initially disabled. The Add button is enabled/disabled depending on whether the NSTextField is empty or not. This is done by implementing the
- (void)controlTextDidChange:(NSNotification *)aNotification
method in the delegate for the textField.
After the Add button is clicked, the entry in the textfield gets added to the dataSource for the tableview, and the textfield gets blanked out:
{textField setStringValue:@""}
(replaced brackets with braces because the posting software turns that into strikethrough)
however, it is apparent that the delegate methods of the textField are not called when the contents are edited programmatically. Question: what is the appropriate way to get textField to call the delegate method? I would like for this call to follow the same path as a regular textField call. Here's one attempt:
{{textField delegate} controlTextDidChange:(NSNotification*)NSControlTextDidEndEditingNotification};
However, to be truly portable, I also have to check whether or not the delegate actually has the controlTextDidChange: selector (I know how to do that - won't include the code for now). Anyway - is this the correct and accepted way of doing this in Cocoa, or am I missing something more obvious and more elegant?
Message was edited by: YuriNiyazov
2.0ghz MacBook (Late 2008), Mac OS X (10.5.5)