views:

243

answers:

2

My experience is in Java development with Eclipse, where if I add a protocol in a header file there is a shortcut to add the required methods of that protocol in the implementation file. Does Xcode have a similar shortcut?

For example: In my .h, I define a class to conform to the UIPickerViewDelegate and UIPickerViewDataSource protocols.

@interface Something : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource> {

}

These protocols have required methods that I need to implement, and I am always checking the documentation to see which ones. Is there some method for Xcode to insert stubs for these required methods in the implementation file?

+1  A: 

So you're asking if, when you type an @protocol command in an ObjC header file, can Xcode automatically put the @synthesize in the .m file?

No. You have to do it manually. There is no built-in way to do this, although someone may have written a script to do that.

CajunLuke
maybe some misunderstanding, updated my question.
Tattat
I rewrote the question. Please correct if I've misunderstood it.
Abizern
I'm sorry. I mixed up `@protocol` and `@property`. My mistake.To answer your actual question, no. Xcode doesn't do that automatically, either. The full list of methods you need to/can implement is in the documentation for the property. That's the only resource I'm familiar with.Sorry for the confusion.
CajunLuke
O.... ...feel disappointed.
Tattat
A: 

I wondered the same thing and I found this neat trick:

http://stackoverflow.com/questions/1206500/what-is-the-most-efficient-way-in-xcode-to-add-a-delegates-or-protocols-methods

I've been finding it very useful. Basically you rightclick the protocol name, and choose "Jump to definition" - it takes you to the relevant header file, from whence you can just copy and paste the relevant declarations. Still a little manual but far less so.

Alan Rowarth