My Blog List

Saturday, September 3, 2011

Current Study Plan

Hummm from this blog, it may look like I quit working on learning objective-c. In fact that's not true. I just quit writing posts about it.

Course I'm following:

1) I spent the summer really focusing on just the language of Objective-C. I did detour a little while investigating and trying out the exercises from the O'Reilly book I wrote about in my last entry. But that was just a bunch of new stuff to learn. I got stuck in chapter 3 (even though I paid attention to the author's caveats and read comments at his forum). And decided that I would go back to that book later. Learning Objective-C is what I reeally want to do.

So I did MOST of the chapters in the Objective-C for Dummies book. The ones that had programming tutorials.

2) Then I sat down and tried to create some of my own examples. What I noticed was, that I still think like a structured programmer! So my approach is off.

3) Therefore.... I'm taking a Java class this fall. It's a basic intro to Java (a language I want to work with anyway).  I'm doing the reading carefully, doing the homework and then I'm working to RECREATE the Java class homework in objective-c.  First I"m working on creating console-output type exercises. Then I work on making GUI/Interface Builder type exercises.

I like this approach because it's giving me abundant problem solving practice with the language alone. Also it's helping me to always think in terms of working in objects.

4) I look for ideas and pointers in the StackOverflow forum a lot. What a great bunch of people to share their time so generously.

Saturday, June 25, 2011

Testing Stark's O'Reilly book

Oh dear, I just discovered a book that is going to take me off-track, but I think it's worthy of investigation!

It's Building iPhone Apps wiht HTML, CSS, and JavaScriptby Jonahtan Sark (O'Reilly)


I'm testing the just-my-own-html capabilities of blogger, wondering if I have to go and setup an actual web page or if this will do the trick for now.
I certainly did a lot of html tagging at one point in my life, and it would be fun to go back to it

Well blogger does put it's default tags in. How much is that going to throw me?

Probably I better setup a regular web page through comcast. I remember that was kind of a page last time I tried. Gee, I bet there is some place I can get a free student web page.

Syntax Review Continued: Focusing on Dot Notation

Dot notation page 147 Goldstein's Objective-C book

* Here the author has an example with dot notation. The class is 'vacationBudgetEurope'. Two of the ivars declared in the interface for that class 'exchangeRate' and 'budget' are referred to in these lines of code.

vacationBudgetEurope.exhangeRate = 1.2500;
vacationBudgetEurope.budget = 1000.00;

Well that makes sense to me.  I think that it may be encapsulation that throws me off when I encounter dot notation in the framework. Because I know it's not always this obvious.
 

Friday, June 24, 2011

Method Declarations: Back to Syntax (Fnishing Gestures and Chapter 11)


Hmmmm I got the tutorial working in the iPad Application Development book, chapter 11. But when I got to the section on gestures there was some syntax I'm unsure about. I need to go back to Goldstein's Objective-C book. I worked on that last year, but clearly I need to do some refreshing.

There's developing abilities with the framework but then every once and a while the language trips me up. I can't afford that when I want to focus on the framework documentation. So back-to-grass-tacks for awhile. What are grass tacks anyway? Am I even remembering the idiom correctly?

Going to summarize syntax as I go, starting with chapter 6 of the objective-c book.
  1. Method declarations are like function prototypes in Objective-C (page 146-7)
    1. When there's only one argument, I'll see just one ':' but there are lots of methods that take more than one argument. The number of ":"'s (colons) shows how many argments there are
    2. The code below declares the "createBudget:: method. It has two argments
    3. -(void) createBudget:(double) aBudget 
    4. withExchangeRate: (float) anExchangeRage;
    5. The COLON is considered to be a PART OF THE METHOD NAME
    6. If there are no colons than there are no arguments
  2.  The real method name is createBudget:withExchangeRate 
  3.  Notice that "("'s are used around both the 
    1. return value
    2. argument/data types - because we are casting one type to another (chapter 4)
  4. Inside of the method I am declaring, I will access the arguments using the identifier names 'aBudget' and 'anExchangeRate'

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.

Tuesday, June 14, 2011

Study Notes: Syntax, Picking Apart the UIColor example

Study Notes: Syntax UIColor example



* Notice there are examples linked from frameworks class documentation. Studying these has been suggested in class and by Goldstein for learning
…..
What the following

   theTextField.textColor    =[UIColor blueColor];

seems to boil down to is

…. Set the textColor attribute (property) of my ‘theTextField’ ivar to be BLUE.


And here are all the details I went through to figure that out
….
I want to better understand this line of code from page 236

    theTextField.textColor =[UIColor blueColor];

“theTextField”

·    is a pointer I defined in the interface file associated with this implementation file.

@interface SettingsViewController : UIViewController {
    <SettingsViewControllerDelegate> delegate;
    float                       sliderValue;
    IBOutlet  UITextField   *theTextField;

·    The pointer is of type UITextField, a frameworks class
·    The part that follows theTextField uses dot notation
o     I THINK textColor is an instance method associated with UITextField



Let’s see if I can figure that out

·     option+ command on UITextField
·     follow link to ()delegate Protocol

NO DICE NO REFERENCE TO textColor


Overview
A UITextField object is a control that displays editable text and sends an action message to a target object when the user presses the return button. You typically use this class to gather small amounts of text from the user and perform some immediate action, such as a search operation, based on that text.
In addition to its basic text-editing behavior, the UITextField class supports the use of overlay views to display additional information (and provide additional command targets) inside the text field boundaries. You can use custom overlay views to display features such as a bookmarks button or search icon. The UITextField class also provides a built-in button for clearing the current text.
A text field object supports the use of a delegate object to handle editing-related notifications. You can use this delegate to customize the editing behavior of the control and provide guidance for when certain actions should occur. For more information on the methods supported by the delegate, see the UITextFieldDelegate protocol.


Go back up a level looking for textColor (some kind of method I think….)

It is a property of the UITextFieldClass. Don’t quite understand that. I know I use the property declaration to substitute for accesors. Well I least I see it that is something



OK back to

    theTextField.textColor =[UIColor blueColor];

I know that [] syntax means that I’m messaging an object. “Many methods in UIKit require you to specify color data using a UIColor object, and for general color needs it should be your main way of specifying colors. “
 So I’m messaging the UIColor class from the blueColor method.

I guess that I’m saying…. Set the textColor attribute (property) of my ‘theTextField’ ivar to be BLUE.





Understanding UIColor use


·     option+ command on UIColor to get documention

Overview
A UIColor object represents color and sometimes opacity (alpha value). You can use UIColor objects to store color data, and during drawing you can use them to set the current fill and stroke colors.
Many methods in UIKit require you to specify color data using a UIColor object, and for general color needs it should be your main way of specifying colors. The color spaces used by this object are optimized for use on iOS-based devices and are therefore appropriate for most drawing needs. If you prefer to use Core Graphics colors and color spaces instead, however, you may do so.
Most developers should have no need to subclass UIColor. The only time doing so might be necessary is if you require support for additional colorspaces or color models.


·     UIColor is the class
UIColor Class Reference
Inherits from
Conforms to
Framework
/System/Library/Frameworks/UIKit.framework
Availability
Available in iOS 2.0 and later.
Declared in
UIColor.h
UIInterface.h
·      
·     blueColor is a class method assoc. with UIColor
blueColor
Returns a color object whose RGB values are 0.0, 0.0, and 1.0 and whose alpha value is 1.0.
+ (UIColor *)blueColor
Return Value
The UIColor object.
Availability
·                       Available in iOS 2.0 and later.

Study Notes: On PROTOCOLS and DELEGATES



Finally, I am starting to get a better sense of the use of protocols and delegates.  The light that went on today was as a result of page 235 in Goldstein/Bove's iPad Application for Dummies, 2nd edition.

It helps that I'm picking through the example tiny bit by tiny bit, like I'm looking for gold dust in a big pan of water, rock and dirt. (Not a reflection on objective-c!)

"The methods that a class delegates are defined in a protocol..... (using).... the @protocol directive."

"Protocols declare methods that can be implemented by any class."

 .....

Previous helpful references from one of following page groups 204, 234-5, 318

* One object delegates the task of implementing one of it's methods, to another object

* Methods a class delegates are defined in a protocol