nifCody
nifCody

Reputation: 2444

Calling a button click event in another function iOS objective-c

I have a trigger to catch the button click on my controller like this

[saveButton addTarget:self action:@selector(save:) forControlEvents:UIControlEventTouchUpInside]; and the relevant function is

- (void)save:(id)sender {
     //implementation code
}

How do call this function in another function, I try to call this function like as follow but it showing error.

(void)checkStatus{
    if(somecondition){
      [self save];
    }
}

Note that I am new to iOS and Objective-C and I am editing a code of another developer. Please give me a solution.

Upvotes: 0

Views: 2126

Answers (1)

Anbu.Karthik
Anbu.Karthik

Reputation: 82766

your button action has a parameter , so you need to append in the parameter as nil or self.do like

- (void)checkStatus{
if(somecondition){
  [self save:nil];
}
}

Upvotes: 2

Related Questions