In Visual Studio if I define a class to implement an interface e.g.
class MyObject : ISerializable {}
I am able to right click on ISerializable, select "Implement Interface" from the context menu and see the appropriate methods appear in my class definition.
class MyObject : ISerializable {
#region ISerializable Members
public void GetObjectData(SerializationInfo info,
StreamingContext context)
{
throw new NotImplementedException();
}
#endregion
}
Is there anything anything like this functionality available in Xcode on the Mac? I would like to be able to automatically implement Protocols in this way. Maybe with the optional methods generated but commented out.
XCode currently does not support that kind of automation. But: an easy way to get your code bootstrapped with a protocol is to option-click the protocol name in your class declaration
@interface FooAppDelegate : NSObject <NSApplicationDelegate,
NSTableViewDelegate> {
to quickly open the .h file defining the protocol. From there, copy and paste the methods you're interested in. Those headers tend to be well-commented, which helps in determining which methods you can safely ignore.
I have not seen that feature in Xcode. But it seems like someone could write a new user script called "Place Implementor Defs on Clipboard" that sits inside of Scripts > Code.
You did not find this useful.
There is not currently such a refactoring in Xcode.
If you'd like it, please file an enhancement request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With