Don't know where to start. Bindings or something else?

I’ve look everywhere for this:

How do I automatically made an action run from a user editing a text field?

Example:
You want to make sure that the data in the text field is always saved, so you make it connected to an action that would be run when the user edited the text field. That action would have NSUserDefaults saving the contents of the text field into a PLIST file.

Anyone? Please… I looked EVERYWHERE! I’m stumped.

Hi,

look at textDidChange: and textDidEndEditing: notification of NSTextField

Ooh… What about controlTextDidChange: ?

it’s actually the same (controlTextDidChange: belongs to the parent class NSControl), but it depends on the context. Sometimes controlTextDidChange: works while textDidChange doesn’t

OK… Now I’m going to do “controlTextDidChange:”, but how do I put it into my code?
Do I put it in there like this

on controlTextDidChange_(sender)
	
end controlTextDidChange_

or like this?

on controlTextDidChange_(notification)
	
end controlTextDidChange_

What would I do in IB?

My knowledge of AppleScriptObjC is quite poor, because personally I regard ASOC as neither fish nor fowl.

In Objective-C you have to make a delegate binding from NSTextField to the custom controller class and implement the notification method

My opinion is the other way around. :confused:

Hm… can you make a simple Objective-C app for me that does exactly that and send it to my email? Just something that could take you 5 minutes. Please?

Done

OK! You make the text field the delegate. What happens if you have multiple text fields? Is it multiple scripts?

OK. I found out everything. MYSELF! :smiley:

I normally have to ask you guys, but I got everything all myself. :smiley:

That’s a good description in some ways. A flying fish can be very useful at times :slight_smile:

Someone understands. :lol:

I have a very small question: Is it OK to save a password into User Defaults? The app would open it up automatically, anyway.

Not if you want to keep it secret, unless you encode it somehow.

How? There has to be an Objective-C method for that!

Why not just use the keychain to store a password. This is really the place to store passwords and sensitive information. Even better, it’s easily done with applescript.