On Oct 8, 2008, at 9:41 AM, Lee, Frederick wrote:
So all my iVars are accessed via:
@property(nonatomic, retain) iVar; // array, dictionary, etc. <--
collections & objects.
Also, I'm not subclassing these properties.
I've seen examples of releasing the iVars & setting their pointers to
nil.
So I figure, using the self.iVar = nil;
No, that is not Apple-sanctioned best-practice.
So you say:
1) use the [iVar release] directly; yet
2) use the "self.iVar = nil" approach for 'synthesized instance
variables.'
Yes, for synthesized *instance variables*.
So if I understand correctly, what you're saying is that in my
particular circumstance (nonatomic),
'nonatomic' has nothing to do with it.
(and I'm synthesizing collections, strings & objects)
the preferred way is setting the 'self.iVar' to nil; per your example
below.
Correct?
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 (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]