Re: Key-Value Coding Limitations
Re: Key-Value Coding Limitations
- Subject: Re: Key-Value Coding Limitations
- From: Graham J Lee <email@hidden>
- Date: Fri, 12 May 2006 11:38:07 +0100
On 6 May 2006, at 02:36, Jonathon Mah wrote:
Hi Mike and James,
On 2006-05-06, at 02:07, Mike Abdullah wrote:
Besides, you really ought to be using accessor methods, rather
than directly editing the object in any case.
Yes, I know. I was a bit unclear in my original e-mail; this is for
a plug-in to an existing application. The plug-in poses a couple of
classes over the application, and these posing subclasses require
access to some instance variables of their superclasses that don't
have accessors. So I can change the plug-in code, but no the
application code (i.e. I can't add accessor methods).
It breaks encapsulation (i.e. it *does* count as directly accessing
the ivars), but this could be a job for @defs:
#import <Foundation/Foundation.h>
@interface GLWibble:NSObject
{
int x;
double y;
}
@end
@implementation GLWibble
-(id)init {
if(self=[super init]) {
y=3.0;
x=1;
}
return self;
}
@end
typedef struct { @defs(GLWibble) } *CGLWibbleRef;
int main (int argc, const char * argv[]) {
GLWibble *myWibble=[GLWibble new];
CGLWibbleRef coreWibble=(CGLWibbleRef) myWibble;
printf("x:\t%d\ny:\t%g\n\n",coreWibble->x,coreWibble->y);
return 0;
}
Cheers,
Graham.
--
Graham J Lee
"Oxford University's UNIX Expert"
As seen in MacWorld UK
http://iamleeg.blogspot.com
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden