My Blog List

Wednesday, June 15, 2011

Study Notes: Syntax, Picking apart UILabel (sliders)


Study Notes Wednesday, June 15, 2011

Picking apart another line of code to study syntax,  from example on page 236

   sliderDisplay.text = [NSString stringWithFormat:@"%.2f", slider.value);

This is how I’m currently interpreting this line of code.

I’m messaging the NSSTring class to put the value attribute of slider (of type UILabel), a string of a certain format, into the text portion/value of the DISPLAY version of a slider.  I guess they are different because I’ll probably use the sliderDisplay in a view and the slider.value is just where I store things that I may be changing internally. And maybe this has to do with keeping things on the view separate from things I operate and do math on, etc. the value of slider is probably something I change directly. Maybe….

Here are the ideas that I used to figure out my current interpretation.

* Ways to figure out what “.text” means
o   Command option help
o   Check code sense in book
o   Check settings


My sense is that it is an attribute, a property of files of the type/class that sliderDisplay is. Because when I do a ctrl click on it, several classes come up.

So First I will see what class sliderDisplay is in my interface.

IBOutlet    UILabel     *sliderDisplay;

So now when I jump to definition for text, I will look for the one associatd with UILabel




   sliderDisplay.text = [NSString stringWithFormat:@"%.2f", slider.value);

So I think that sliderDisplay is an ivar that can be composed of different pieces/ivars depending on what I need. And I think that .text is one of the pieces/ideas/attributes/properties that I want to address.

I think that I’m saying that I’m picking up a value (the value attribute of the slider object)
    IBOutlet    UISlider    *slider;
    IBOutlet    UILabel     *sliderDisplay;
}

I’m messaging the NSSTring class to put the value attribute of slider (of type UILabel), a string of a certain format, into the text portion/value of the DISPLAY version of a slider.  I guess they are different because I’ll probably use the sliderDisplay in a view and the slider.value is just where I store things that I may be changing internally. And maybe this has to do with keeping things on the view separate from things I operate and do math on, etc. the value of slider is probably something I change directly. Maybe….

·     Notice that ‘text’ and ‘NSString’ are both colored purple.
o    I know that ‘NSString’ is a framework class.
o   What does that tell me about ‘.text’?
o   It’s not a framework class because it doesn’t start with a capital letter
o   It uses dot notation, which I thought could be a method or an ivar.     LOOK IN THE OLDER BOOK FOR DOT NOTATION   
o   Preference settings indicates it could be a CLASS or a TYPE or IVAR or GLOBAL name
o   But I don’t think MY ivars are purple, ‘other’


·     Reencountered the apple documentation on objective-c and programming in objective – c. Good time to look at this again. Plan to start reading through this today after I work a little more on this example.

No comments:

Post a Comment