Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Vidarious

macrumors newbie
Original poster
Nov 27, 2010
5
0
Hi guys, I'm currently learning Objective C for iPhone dev and using a lot of the documentation to help understand the syntax. I've come across a property that I can't find declared anywhere.

For the class UILabel there is a property called "text". Which you can see in the UILabel documentation. However there is also a property called "setText" which allows you to change a UILabel object. However "setText" is nowhere to be found!

The quick help for setText is as follows:

Name: setText:
Declaration: @property(nonatomic, copy) NSString *text
Availability: iOS (2.0 and later)
Abstract: The text displayed by the label.
Declared in: UILabel.h
Reference: UILabel Class Reference

When you look in UILabel.h or the documentation for UILabel there is no such thing as "setText" --- only "text". How can I use "setText" if it isn't declared?
E. [display setText:[NSString stringWithFormat:mad:"%g", result]]; works fine.
 
Objective-C Programming Language : Property Declaration Attributes
The default names for the getter and setter methods associated with a property are propertyName and setPropertyName: respectively—for example, given a property “foo”, the accessors would be foo and setFoo:. ...etc...

There are not two properties, text and setText:. There is only one property, text. It has a setter accessor named setText:.

You should read the entire section for Declared Properties.
 
This explains a lot! That explains why I couldn't find an exact declaration or setText.

Thank you
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.