• 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
virtual ivars
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

virtual ivars


  • Subject: virtual ivars
  • From: Todd Heberlein <email@hidden>
  • Date: Sat, 29 Aug 2009 13:49:30 -0700

I've been playing with KVC and KVO with my own setters and getters (along with Controllers) to create virtual ivars. That is, there never is any storage created for the variable and its value is calculated on the fly when the getter is called. This seems to have some cool potential, but it raises the following question:

	Could this break with future Xcode or OS X upgrades?

In other words, is this approach an officially supported way to code by Apple, or do they have the freedom to break this in the future?


Thanks,

Todd


Simple example where the ivar "myInt" never really exists:

@interface MyObj : NSObject <NSApplicationDelegate> {
    NSWindow *window;
}
@property (assign) IBOutlet NSWindow *window;

-(int)myInt;
-(void)setMyInt:(int)newVal;

@end


....

-(int)myInt
{
	return 43;
}

-(void)setMyInt:(int)newVal
{
	// do nothing right now
}


_______________________________________________

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: virtual ivars
      • From: Ken Thomases <email@hidden>
    • Re: virtual ivars
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Core Data observer exception in 10.6
  • Next by Date: Copying records from to-many relationship in Core Data
  • Previous by thread: Re: Core Data observer exception in 10.6
  • Next by thread: Re: virtual ivars
  • Index(es):
    • Date
    • Thread