controlTextDidChange with 2 nstextfields - call different selectors


cocoa newbie here

i have 2 nstextfields connected with controlTextDidChange. it works fine.

- (void)controlTextDidChange:(NSNotification *)anotif{ [self eval]; }

when either of the textfields change eval is called.

what i want to do is check the textfield that changed and if it's the first one call eval1, if it's the second call eval2.

how can i do this?


Given that the NSTextFields are field1 and field2, all you have to do is check which one of them is the sender object, given along with the notification.


- (void)controlTextDidChange:(NSNotification *)anotif { if ([anotif object]==field1) { // field1 processing } else { // field2 processing } }


OK, I think I found it.

I set tags on both NSTextFields.

Then, I can get the tag number with :

[[anotif object] tag]


  • Truncate beginning of label
  • Simple and concise desktop Cocoa NSXMLParser example?
  • How to override a fullscreen game with keywindow borderless window (overlay)?
  • Send action from NSTextField when on key up instead of return
  • Possible to use NSView subclass in NSTableView?
  • How do I create connected text fields in ios?
  • How to check the text of an NSTextField (Label)
  • UITextfield not editable-iphone [duplicate]
  • SetHidden not working [duplicate]
  • Chartjs not working in IE8, issue with canvas element even after including excanvas
  • What is the reason the UIKeyBoardWIllShowNotification called once?
  • Apache POI JDK version
  • Deselect table view row when returning to app
  • Stream large movie with credential through MPMoviePlayer
  • Update MapKit annotation subtitle and image
  • capture right click through Javascript, withouth wmode
  • Add mod_mysql, mod_xml and mod_zlib to apache
  • NSWindowController subClass - Init is Called twice
  • C# how to click an IWebelement in a IList?
  • Kentico Repeater HTML Properties showing with selected transformation
  • How to change display text in item template based on eval in gridview?
  • Unable to install sqldf on Linux
  • Access variable of ScriptContext using Nashorn JavaScript Engine (Java 8)
  • How to avoid particles glitching together in an elastic particle collision simulator?
  • Recording logins for password protected directories
  • Splitting given String into two variables - php
  • Check if a string to interpolate provides expected placeholders
  • Websockets service method fails during R startup
  • Why winpcap requires both .lib and .dll to run?
  • Calling of Constructors in a Java
  • Traverse Array and Display in markup
  • Transpose CSV data with awk (pivot transformation)
  • Why can't I rebase on to an ancestor of source changesets if on a different branch?
  • How to set the response of a form post action to a iframe source?
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • unknown Exception android
  • EntityFramework adding new object to nested object collection
  • Checking variable from a different class in C#
  • failed to connect to specific WiFi in android programmatically
  • How can I use threading to 'tick' a timer to be accessed by other threads?