virtual ivars
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