Subject: Re: clarification regarding properties
Am 27.03.2009 um 17:24 schrieb WT:
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.
If it is, this would be a major gotcha for Java developers new to
Obj-C. In Java, this.foo = whatever has the exact same effect as foo
= whatever when foo is a member variable of some object
Also, this means that it's best *always* to use the qualified
assignment for properties,
Yes. Or you could just call [self setFoo:whatever] which is what
everyone did before ObjC 2.0 anyway.
since there's a chance that a property might be changed from
assigned to retained or copied (or from nonatomic to "atomic").
You mean if someone changes the header-file? Yes.
The new property assignment syntax is an easy way to get mixed up
between Java, C++ and ObjC 2.0. It was a syntax error before.
Just always use self.foo anywhere if foo is a property and never think
about it again :)
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