• 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: Instance variable access from functions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Instance variable access from functions


  • Subject: Re: Instance variable access from functions
  • From: Luke the Hiesterman <email@hidden>
  • Date: Tue, 21 Apr 2009 19:50:31 -0700

It's done all the time. You should read up on Objective-C 2.0 properties, though, to learn when it's best to use properties.

Luke

On Apr 21, 2009, at 7:40 PM, Seth Willits wrote:


Is the non-protected access of instance variables from functions defined inside of @implementations documented anywhere? I'm wondering if this some secret thing that I shouldn't use, or something that's actually pretty common used?




@interface Foo : NSObject
{
	int special;
}

- (void)print;

@end




@implementation Foo

static inline void dotheprint(Foo * self)
{
NSLog(@"%d", self->special); // If defined outside @imp it'd give a compiler error
}


- (id)init;
{
	[super init];
	special = 5;
	return self;
}

- (void)print;
{
	dotheprint(self);
}

@end




-- Seth Willits


_______________________________________________

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

_______________________________________________

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


  • Follow-Ups:
    • Re: Instance variable access from functions
      • From: Seth Willits <email@hidden>
References: 
 >Instance variable access from functions (From: Seth Willits <email@hidden>)

  • Prev by Date: Re: iphone SDK session duration
  • Next by Date: Re: Instance variable access from functions
  • Previous by thread: Instance variable access from functions
  • Next by thread: Re: Instance variable access from functions
  • Index(es):
    • Date
    • Thread