• 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: Private Methods
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Private Methods


  • Subject: Re: Private Methods
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Fri, 22 Feb 2008 12:28:26 +0100


Le 22 févr. 08 à 12:00, Philip Bridson a écrit :

How do I make a method private?

I have tried putting @private before the method that I want to make private but the compiler flags a parse error. I read the documentation and I can only find reference to private member variables. I want to make sure that a method can only be accessed via another method in the same class. Is this possible in Objective- C or do I need to write this class in C++?

Many thanks.

Phil.


If you realy want to call this method only from your class, you can convert it into a function (instead of using C++).
As long as this function stay in the class implementation (between @implementation and @end) you can access private variable using the self->_ivar syntaxt.


- (void)myPrivateMethod:(id)arg {
	/* do whatever you want */
}

static void myPrivateFunction(MyClass *self, id arg) {
	/* do whatever you want */
}_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Private Methods (From: Philip Bridson <email@hidden>)

  • Prev by Date: Re: Private Methods
  • Next by Date: Re: Private Methods
  • Previous by thread: Re: Private Methods
  • Next by thread: Re: Private Methods
  • Index(es):
    • Date
    • Thread