Synthesized versus Explicit *instance variables*.
Synthesized versus Explicit *instance variables*.
- Subject: Synthesized versus Explicit *instance variables*.
- From: "Lee, Frederick" <email@hidden>
- Date: Wed, 8 Oct 2008 13:44:33 -0400
- Thread-topic: Synthesized versus Explicit *instance variables*.
Your answer got me thinking about Synthesized versus Explicit Instance
Variables.
I've been using Synthesized-Explicit Instance Variables.
That is, explicitly declaring iVars AND per ObjC_2, using
@property/@synthesize
directive to build the assessors.
Is there any benefit of using non-explicit/Synthesized Instance
Variables that you had mentioned?
Ric.
-----Original Message-----
From: mmalc crawford [mailto:email@hidden]
Sent: Wednesday, October 08, 2008 11:56 AM
To: Lee, Frederick
Cc: email@hidden
Subject: Re: In dealloc(): ref @property, Can I use "<property object> =
nil; " vs "[<property object> release]; " ?
No. I stated specifically "synthesized *instance variables*" and gave
an example:
@interface MyClass : NSObject
{} // **** Note: no instance variables
@property (retain) NSString *aString;
@end
@implementation MyClass
@synthesize aString;
-(void)dealloc {
self.aString = nil; // [aString release]; won't work
}
@end
If instead you had an explicit instance variable:
@interface MyClass : NSObject {
NSString *aString;
}
@property (retain) NSString *aString;
@end
then you would use:
@implementation MyClass
@synthesize aString;
-(void)dealloc {
[aString release];
}
@end
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