Quote:
Originally Posted by Bugsy
Hi BrianSlick
Thanks for the quick response.
So they are equal, but what about the setText and text difference ?
Regards
Bugsy
|
Both of those forms set the value of a property.
Read Brian's article on properties. The link is in his signature.
Properties are declared with the @property command.
When you declare a property, you can make it read-only or read/write. If the property is read/write, you wind up with 2 new methods in your code: a getter and a setter.
The getter is a method that has the same name as the property, and returns a value of that type.
The setter is a method called set<Property_name>, where "set" is prepended to the front of the method name, and the property name (with it's first letter capitalized) is the second part of the method name.
So, for a property "text", the setter method is called setText.
You can invoke a setter by calling it with normal method syntax:
Code:
[label setText: @"new value"];
Or using "dot notation", which is new to Objective C 2.0. That looks like this:
Code:
label.text = @"new value";
The compiler actually converts the dot notation form to a normal method call, like the first form.