I am having one problem with UIBarButtons in xCode iOS 4 with Objective-C.
I am following several examples and the error says that the addButtonPressed method was not defined – even though I have the function created before hand like this:
- (void)addButtonPressed
{
NSLog(@"Addbutton pressed", @"");
}
It is also defined in the .h file. Here’s my code:
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemAdd target:self action:addButtonPressed];
self.navigationItem.rightBarButtonItem = addButton;
[addButton release];
Here’s the error:
'addButtonPressed' undeclared (first use in this function)
Am I doing something wrong?
Thanks for the help,
Christian Stewart
You should pass a selector for the action argument instead of the method name.