Jump to content

Iphone SDK Documentation

8 posts in this topic

Recommended Posts

Hi. I am very new to using a Mac and to Objective-C, but so far it all pretty much makes sense, and I am managing to produce some simple apps.


My big headache is when the documentation just seems to go all cryptic on me. I feel like I must be missing something which is obvious to long-term Mac programmers.


Could someone tell me if I am just being a real noob, or whether there is a 'secret' I am missing?


For example, according to the docs, UIView has a property called hidden. It also says that the getter for this property is 'isHidden'. But none of the following seem to work


my_btn.hidden = YES;
[my_btn setHidden:YES];
[my_btn hidden:YES];
my_btn.isHidden = YES];


What is the syntax for setting a property? It seemed from my reading of the documentation elsewhere that the first one is correct, but the SDK errors with


'request for memeber 'hidden' in something not a structure of a union'


Could someone kind bear with me and explain how to read the documentation? What does it mean? If it says 'getter=isHidden' what does that imply? That I should use 'isHidden' instead of 'hidden'? That this is read-only, hence no setter? Is there a standard method for setting and retrieving getter/setters which I just don't know about?


I know this sounds like a really noob question - but I don't want spoon-feeding, just an idea of how to interpret the documentation generally.. thanks very much.

Link to comment
Share on other sites

What exactly is "my_btn"? It would have to be a UIView or a subclass of a UIView for it to work.


The proper syntax for read-write properties is object.property = value. Typically you don't have to use properties, you could use methods: [object setProperty:value]. Properties provide the ability to read and write from one "method."


Hidden is read-write. So you would do myUIView.hidden = YES;, or alternatively [myUIView setHidden:YES];

Link to comment
Share on other sites



my_btn is a UIButtonm, but that was just an example - I was really just hoping someone could clarify the conventions of the docs in general.


This is what it says for this example



A Boolean value that determines whether the receiver is hidden

@property(nonatomic, getter=isHidden) BOOL hidden


So, generally speaking, what does 'getter=isHidden' mean? I am sure 'getter=' is a standard notation, but I just couldn't find an explanation of it anywhere yet. I would guess it means 'there is a getter method which returns the value of hidden, called 'isHidden'. But why would this not be listed with other methods (hard to find this way) and what would be the point of a read-only getter method for a property which has to be set directly?


"Typically you don't have to use properties, you could use methods: [object setProperty:value]"


Agreed. But how do I know what method to call? In this case, the docs show that there is a property called 'hidden', but no corresponding 'setHidden' method is listed, and the compiler doesn't like it.


So does that mean I should set the property directly? Or the method might be called something completely unrelated? Or is there a standard way to work out what the method would be, based on the property? Or is it just a gap in the docs?

Link to comment
Share on other sites

setHidden: takes an argument BOOL. So you would use setHidden:YES. hidden is used as setHidden: in the documentation — if you do an exact search and type in setHidden:, you will get a result under UIView that will take you to the hidden property.

Link to comment
Share on other sites

  • 2 weeks later...

To actually answer your question, using properties is always best.


So, foo.hidden = YES, is always better than [foo setHidden:YES]


Well, I guess it's not really better, but easier, and it works both ways, instead of having setter and getter methods.


Properties do include getter and setter methods FYI

Link to comment
Share on other sites


  • Create New...