• 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: @properties and Information Hiding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >@properties and Information Hiding (From: Karl Goiser <email@hidden>)
 >Re: @properties and Information Hiding (From: Raffael Cavallaro <email@hidden>)
 >Re: @properties and Information Hiding (From: Karl Goiser <email@hidden>)

  • Prev by Date: Re: @properties and Information Hiding
  • Next by Date: Core Data property declaration
  • Previous by thread: Re: @properties and Information Hiding
  • Next by thread: Re: @properties and Information Hiding
  • Index(es):
    • Date
    • Thread