I have a method @selector with parameter of type NSString. when I compile the app I get this error
No visible @interface for 'UIButton' declares the selector 'addTarget:action:
withObject:forControlEvents
The method is declared in header file.
This is the code:
-(void)loadDetailListViewController: (NSString *)nameTable{
//......
}
- (MKAnnotationView *)mapView:(MKMapView *)mapview viewForAnnotation:(id
<MKAnnotation>)annotation
{
//.....
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton addTarget:self action: @selector(loadDetailListViewController:)
withObject:self.nameTable forControlEvents:UIControlEventTouchUpInside];
//here the error
//.....
}
I don’t know if the parenthesis are right
that method does not exist. This does
If you need to pass a string to the method, I would suggest subclassing UIButton with a string property and you can set it there. The button is passed as a parameter in your selector so you can get it and the string from there: