• 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: Objective 2.0 properties
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objective 2.0 properties


  • Subject: Re: Objective 2.0 properties
  • From: Ken Thomases <email@hidden>
  • Date: Fri, 17 Oct 2008 23:03:23 -0500

On Oct 17, 2008, at 10:47 PM, Ignacio Enriquez wrote:

I'm starting to think that you should avoid declared properties and dot
syntax for now. With some of the newer features of Objective-C and Cocoa,
it can be helpful for novices to first become proficient with the "old way"
so they understand the details which are hidden by the "new way".
In other words, perhaps you should get comfortable writing your own
accessors instead of letting Objective-C synthesize them for you. And you
should explicitly invoke them throughout your code, rather than blindly
coding without understanding what's happening (with dot syntax, for
example).

just to confirm... (from http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_5_section_6.html#)

// assign
property = newValue;

// retain
if (property != newValue)
{
   [property release];
   property = [newValue retain];
}

// copy
if (property != newValue)
{
   [property release];
   property = [newValue copy];
}

So retain is more or less what I want.

Is it? In your original message, you had properties of NSString and NSNumber type. It is much more likely that, with those and other value types, that you'd want to copy.


 this means that instead of
writing getters and setter  methods  I can write
@property(retain) myproperty
and then in the implementation part
@synthesize myproperty
and I should have the same result to the above retain regarding code.
is this ok?

Yes. Declared properties and their synthesized accessors are mostly just ways to automate generation of the classic accessors. (And dot syntax is just a way to generate calls to those accessors.) So, if you understand the way the accessors work and you know which one(s) you want, then, yes, feel free to use declared properties and dot syntax.


Cheers,
Ken

_______________________________________________

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: 
 >Objective 2.0 properties (From: "Ignacio Enriquez" <email@hidden>)
 >Re: Objective 2.0 properties (From: Charles Steinman <email@hidden>)
 >Re: Objective 2.0 properties (From: "Ignacio Enriquez" <email@hidden>)
 >Re: Objective 2.0 properties (From: Ken Thomases <email@hidden>)
 >Re: Objective 2.0 properties (From: "Ignacio Enriquez" <email@hidden>)

  • Prev by Date: Re: Screen not redrawing
  • Next by Date: CompositeToPoint - avoid its use?
  • Previous by thread: Re: Objective 2.0 properties
  • Next by thread: Re: Objective 2.0 properties
  • Index(es):
    • Date
    • Thread