Xcode, have delegate method auto-include classes

161 views Asked by At

In Xcode I would like to add a delegate such as UITextFieldDelegate and have methods such as textFieldShouldReturn auto added to my document

In Java when I include an interface, my IDE typically forces me to auto-add some particular classes, which I tend to add code into.

Is there any way to do this in Xcode?

1

There are 1 answers

0
Ben Kane On BEST ANSWER

All of the methods in the UITextFieldDelegate protocol are optional, so Xcode won't give you any warnings. If you try something like UITableViewDataSource, you'll see Xcode gives you warnings for the required methods that your class hasn't implemented.

I don't know of a way to auto-fill those methods, but it's really easy to cmd+click UITextFieldDelegate and copy/paste the methods you need. It's possible that there is an Xcode plugin out there that would auto-fill the required methods for you.