views:

56

answers:

1

In this:

-(IBAction)buttonClick: (id)sender {
    UIActionSheet *actionSheet = [[UIActionSheet alloc]
             initWithTitle:@"Fo Sho?"
             delegate:self
             cancelButtonTitle:@"Cancel"
             destructiveButtonTitle:@"fo sho"
             otherButtonTitles:nil];
    [actionSheet showInView:self.view];
}

A UIButton would be linked to this "buttonClick" IBAction but what is "self"?

+1  A: 

self is the equivalent to this in many other languages such as C++. In other words when you call [myString length], the self pointer inside the length message is the pointer to your string named myString.

-(void)logScore
{
    NSLog(@"%@ score is %d", self.name, self.score);
}

[player logScore];

In the example, self is the player object.

Nick Bedford
what about in my specific example? Would it be UIButton or UIView or UIViewController?
Devoted
if buttonClick is method of View controller, then it will be view controller.if buttonClick is method of View then it will be view.
Valerii Hiora
It would be an instance of the class to which the `#buttonClick:`-Method, you are showing to us, belongs to. Most probably an `UIViewController` but since you are not showing us any more code this is just a guess
nils