Subject: Re: clarification regarding properties
On Mar 27, 2009, at 10:24 AM, WT wrote:
foo = whatever
just sets the value of foo to the value of whatever, but
self.foo = whatever
actually calls the method setFoo: with whatever as its argument.
This difference is important because the setter method might do some
necessary memory management which the simple unqualified assignment
Is my understanding correct?
If it is, this would be a major gotcha for Java developers new to
Correct; ObjC does things the other way around from Java and C#. This
is because ObjC is a true superset of C, and C is of course purely
procedural, and Java and C# are not supersets of C and can do things
Also, this means that it's best *always* to use the qualified
assignment for properties, since there's a chance that a property
might be changed from assigned to retained or copied (or from
nonatomic to "atomic").
Not always. If you're not using GC, then you may need to keep strong
references to objects, or they might be deallocated behind your
object's back, which would not be a very good thing. So I'd recommend
using accessors unless you have a good reason to not do that.
Cocoa-dev mailing list (Cocoa-dev@xxxxxxxxxxxxxxx)
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 maillists@xxxxxxxxx