Hi! New to forums and a couple newbie syntax questions

Discussion in 'iOS Programming' started by Dekejis, Jun 17, 2011.

  1. Dekejis macrumors newbie

    Joined:
    Jun 17, 2011
    #1
    Hi everyone, I'm glad to have found a forum where I can get together with other iOS enthusiasts!
    I've been learning for a little over a month now, but I have a couple syntax questions I'm hoping to get a little clarification on, since i can't seem to find an explanation on when to use a couple things and when not to, and I want to really understand.

    1. In the partial example -(NSInteger)tableView:(UITableView *)tableView
    What specifically does that asterisk represent and when is it used? I am guessing perhaps with certain datatypes and not with others?

    2. I am working with a tutorial on navigation-based table views. And the example uses an array for a datasource. I am noticing that references in this example are prefixing the array references with self., as in self.myArray whereas other variables I've worked with before have not. I understand, I believe, the self. prefix, but I am unsure - when is it appropriate to use this prefix with a variable and when not?

    Anyway, I appreciate any input (and sorry for the newbie questiand right off the bat) and I'm glad to have joined the group!
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    1. That it's a pointer. This suggests you do not have basic C knowledge: step back and take some time to learn C.

    2. self refers to the "current" object, i.e. in instance of the class the method is running against/in. The dot (.) indicates that we are using the property syntactic sugar to access the variable via an accessor method (which is a good idea). Without this you are accessing the variable directly.
     
  3. Dekejis thread starter macrumors newbie

    Joined:
    Jun 17, 2011
    #3
    Thanks, yes, that makes sense. And yes, working on the C bit as well, but wanted a feel for the lay of the land with Xcode 4 vs 3. I've done well, I think, thus far in picking up the programming via inference, but I can see some dedicated C time would be really beneficial to fill in some of the semantics.
     

Share This Page