views:

1515

answers:

4

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.

+2  A: 

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.

David Grant
+2  A: 

There is not currently such a refactoring in Xcode.

If you'd like it, please file an enhancement request.

Chris Hanson
A: 

Macrumors had a discussion on this too. There is a link to some apple scripts. I haven't actually tried these.

Casebash
A: 

Xcode can help you per protocol method, lets say you have a protocol like this:

@protocol PosterousWebsitesDelegate <NSObject>
- (void)PosterousWebsitesLoadSuccess:(PosterousWebsites*)websites;
@end

in the @implementation section of your .m file you can start writing the name of the method and pressing ESC key to autocomplete the signature of the method/selector:

-(void)Poste (...press ESC...)

Xcode will autocomplete a full signature of the @protocol method, pres TAB to confirm the code.

If you are really committing to learn OSX/iOS Development, I would recommend you to read "XCode 3 Unleashed", a book that really helped me to know Xcode as deep as I know VS :)

thepumpkin1979