• 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
Synthesized versus Explicit *instance variables*.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Synthesized versus Explicit *instance variables*.
      • From: Charles Steinman <email@hidden>
References: 
 >In dealloc(): ref @property, Can I use "<property object> = nil; " vs "[<property object> release]; " ? (From: "Lee, Frederick" <email@hidden>)
 >Re: In dealloc(): ref @property, Can I use "<property object> = nil; " vs "[<property object> release]; " ? (From: mmalc crawford <email@hidden>)
 >RE: In dealloc(): ref @property, Can I use "<property object> = nil; " vs "[<property object> release]; " ? (From: "Lee, Frederick" <email@hidden>)
 >Re: In dealloc(): ref @property, Can I use "<property object> = nil; " vs "[<property object> release]; " ? (From: mmalc crawford <email@hidden>)

  • Prev by Date: Re: CALayer bounds with ResizeAspect mask?
  • Next by Date: Re: NSIndexSet isEqual: sent to deallocated instance
  • Previous by thread: Re: In dealloc(): ref @property, Can I use "<property object> = nil; " vs "[<property object> release]; " ?
  • Next by thread: Re: Synthesized versus Explicit *instance variables*.
  • Index(es):
    • Date
    • Thread