Some newbie syntax questions

Discussion in 'iOS Programming' started by gizzerd91, Jul 16, 2009.

  1. gizzerd91 macrumors newbie

    Joined:
    Jul 15, 2009
    #1
    Why is it that IBAction functions have a semicolon in them right before the curly brackets, while all other functions I am aware of do not?

    Code:
    - (IBAction)click: (id)sender;
    {
    Why does the asterisk, which I assume is for declaring a the new variable "application", come inside of the parenthesize?

    Code:
    - (void)applicationDidFinishLaunching: (UIApplication *)application {
     
  2. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    It is an oddity of Objective-C syntax that placement of a semicolon before the curly brace is optional. There's nothing special regarding IBActions in this regard; it's the case for all methods.

    The star indicates that this is a pointer. You read pointer expressions like this from right to left. Pointer to UIApplication object. You need to read more about this in a book about C and then one about Objective-C. In the line of code that you show the pointer expression is the type of the parameter named application.
     

Share This Page