Question

I'm trying to extend the NameAndPassword code sample so that the secure text fields run authentication action on return key press (currently the authentication only works if the button is pressed through the buttonPressed action).

I tried various options - creating a xib file along with ViewController to replace the existing nib file, but in such case I can't create a connection between the xib custom view and the IBOutlet that was connected to the view in the nib file before I removed it.

I also tried connecting the existing secure password field from the nib file to an App Delegate I created myself, but it doesn't want to work either - I control-drag the textfield to the appdelegate.h interface section but no lines show up.

I know this sample is very outdated now - my question is, how can I create custom actions on these views or how to recreate this project on a fresh surface?

No correct solution

OTHER TIPS

IIRC you can't connect target-action on custom views. It only works with Apple-provided views and subclasses thereof (so if your view was a subclass of NSControl, it would work). However, you can always call setTarget: and setAction on your view in the awakeFromNib (or equivalent) method of whatever object owns the NIB.

If your class is already a subclass of another Apple-class that supports target/action, there is probably a syntax error somewhere in your code, or an #if/#ifdef or the like that makes the Interface Builder part of Xcode unable to correctly parse your class. In that case it often leaves it out, and you get none of its IBOutlets listed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top