On Apr 17, 2008, at 11:38 AM, Rama Krishna wrote: I have worked (and still do) intensively in Visual Studio/Eclipse/NetBeans. I have just started using XCode a month back and learning Mac/iPhone development and I love it. I have a few questions: 1. Is there an IDE support for quickly implementing(adopting?) a protocol in a class? Is it possible to create method stubs for a protocol in a class interface and the implementation files automatically (without manual typing or copy paste)? 2. Is there a quick way to override a method (again without Copy/Paste)? If XCode does not natively support these are there add-ins available to do these tasks? Of course, they are not a big deal but if the IDE offers these productivity enhancements why not use them. Also what some cool and popular add-ins for XCode?
I guess I'm not sure what you mean by "a protocol in a class". You can define a protocol inside of a class header file, certainly, and then conform to that protocol and implement its methods in your class implementation. This is actually done quite a bit with dynamic method generation such as is used with Core Data - if you automatically generate model classes from Core Data entities, you'll see that it creates a protocol for the methods that go along with one-to-many associations. Other than code completion for known objects, however, I don't believe there is anything to automatically do this for you. But I think I'm not fully understanding what you want Xcode to do for you, because I'm having trouble picturing how the IDE would handle this task for you.
The second question I have is: are you sure a protocol is the correct way to do what you want to do. In many situations where a protocol would be used in other languages, a category is actually more appropriate in Objective-C, and I find that a lot of people who are new to the language tend to overuse protocols and underuse categories. If you need advice on that regard, the Cocoa-dev list would be a more appropriate place to ask.
As for #2, if you are overriding a method, the method autocomplete should recognize the method name from the superclass and save you some typing, but there is no key combination or other option AFAIK where you can specify "i want to override this method" and have it create the method stub for you.
Jeff |