开发者

Is there an easy way for Xcode to let me know which methods of a protocol are required?

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开发者_Go百科 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?


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.


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

What is the most efficient way in XCode to add a delegate's or protocol's methods to the .m file?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜