• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: A few IDE support questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A few IDE support questions


  • Subject: Re: A few IDE support questions
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Thu, 17 Apr 2008 19:10:13 +0200


Le 17 avr. 08 à 18:40, Jeff LaMarche a écrit :


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.

I think the OP want a function that generate method stubs for a protocol.


For example you say to the IDE to generate stub for NSCoding and NSCopying, and it automatically add all methods from thoses protocol to your class

- (id)copyWithZone:(NSZone *)aZone {
 // Put your copy code here.
}

- (void)encodeWithCoder:(NSCoder *)aCoder {

}
..... etc

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.

Until now, categories are used to defined informal protocol, but that should no longer be the case. Obj-C 2 introduce the concept of optional methods in a protocol and all categories used to defined delegate methods, data source and more should be refactored into protocol. (see new NSPathControlDelegate for example)



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 _______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >A few IDE support questions (From: "Rama Krishna" <email@hidden>)
 >Re: A few IDE support questions (From: Jeff LaMarche <email@hidden>)

  • Prev by Date: Re: A few IDE support questions
  • Next by Date: Re: G4 867mhz, Leopard, and XCode 3
  • Previous by thread: Re: A few IDE support questions
  • Next by thread: Adding Apple Pages document to subversion repository
  • Index(es):
    • Date
    • Thread