Re: @properties and Information Hiding
Re: @properties and Information Hiding
- Subject: Re: @properties and Information Hiding
- From: mmalc crawford <email@hidden>
- Date: Thu, 1 Nov 2007 18:23:57 -0700
On Nov 1, 2007, at 3:57 PM, Karl Goiser wrote:
<interface file>
@interface MyClass : NSObject {
NSString *value;
}
- (NSString *) value;
@end
<implementation file>
@implementation MyClass
- (NSString *) value {return value};
- (void) setValue: (NSString *) stringParameter {
[stringParameter retain];
[value release];
value = stringParameter;
}
@end
Thinking about this a little more, of course there's a further deficit
in this example: in the general case it only really works if you make
sure your implementation of the set method precedes all the other code
that use it. Otherwise, when you use a property name such as
firstName (and hence have setFirstName:, which the compiler doesn't
know about -- contrast setValue:) you'll get compiler warnings...
So typically you still have to declare the set accessor somewhere...
mmalc
_______________________________________________
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