My Blog List

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'

No comments:

Post a Comment