• 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: Xcode Refactor Extract…
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Xcode Refactor Extract…


  • Subject: Re: Xcode Refactor Extract…
  • From: Chris Hanson <email@hidden>
  • Date: Sat, 17 Dec 2011 21:00:51 -0800

On Dec 14, 2011, at 2:20 PM, James Merkel wrote:

> The extraction of a section of code into a new method works fine (Xcode 4.2.1).
> However, there seems to be one gotcha.
> The newly created method isn't declared in the header file.
> So if you want to call the method again in another section of code (a primary purpose of the extraction is eliminating duplicate or nearly duplicate code) then the compiler complains that the class does not contain that new method. So you have to add it to the header file.
> Maybe not a big deal, but is this a bug, or am I missing something?

If it doesn't work the way you'd expect, it's worth filing a bug report about.

In this case, it's intentional that Xcode doesn't add a declaration of the extracted method to a header file:  Only the *public* interface to a class belongs in its primary @interface section.  (This is different than C++, where every method of a class must be declared as well as defined.)  Often extracting a method is done as part of reorganizing some code's internals, at least initially — exposing the new method as API is a separate conceptual step.

It's certainly reasonable to ask if Xcode could help you expose an extracted method or function as API, too, so please file an enhancement request at <http://bugreport.apple.com/>.  Thanks!

  -- Chris


 _______________________________________________
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

  • Follow-Ups:
    • Re: Xcode Refactor Extract…
      • From: James Merkel <email@hidden>
References: 
 >Xcode Refactor Extract… (From: James Merkel <email@hidden>)

  • Prev by Date: Re: Xcode Refactor Extract?
  • Next by Date: Re: Xcode Refactor Extract…
  • Previous by thread: Re: Xcode Refactor Extract…
  • Next by thread: Re: Xcode Refactor Extract…
  • Index(es):
    • Date
    • Thread