What is the most efficient way in XCode to add a d

2019-01-26 15:28发布

When one implements an interface (equivalent to a protocol in Objective-C) in the .Net environment, the IDE automatically adds the properties and methods that need to be implemented to the class's file. Is there a setting that will result in a similar behavior in the Xcode environment? Will it do the same for a delegate?

At this point, I find myself copying/pasting the protocol/delegate's methods from Apple's online documentation.

3条回答
狗以群分
2楼-- · 2019-01-26 15:48

Instead of xCode, you can use appCode, "Generate" feature is usefull

查看更多
Juvenile、少年°
3楼-- · 2019-01-26 16:02

Copy-and-paste is the fastest way to do it with Xcode 3.1 as available online. A little script to parse a header and spit out protocol defs would be pretty cool, though…

查看更多
Luminary・发光体
4楼-- · 2019-01-26 16:05

sorry for late comment, I use this neat trick.

For example, your class is named "MyClass", you want it to have protocol NSTableDataSource. What you do is write

@interface MyClass : NSObject <NSTableDataSource> 
{ 
   ... usual stuff here ...
@end

then, you right-click on NSTableDataSource, click on "Jump to definition".... and you can copy it from there.

If you want it to be delegate of, let's say again, NSTableView, you just name the protocol NSTableViewDelegate (this is an actual protocol name!), right click on it, click on "Jump to definition" - and you have it there, you just have to ignore those preprocessor marks everywhere.

It's maybe not as easy as with for example Java interfaces and NetBeans, but it's not significantly slower.

查看更多
登录 后发表回答