Re: clarification regarding properties
Re: clarification regarding properties
- Subject: Re: clarification regarding properties
- From: Alexander Spohr <email@hidden>
- Date: Fri, 27 Mar 2009 18:11:17 +0100
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.
Yes.
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
Yes.
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 :)
atze
_______________________________________________
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