Reputation: 1
I am new to objective C, So maybe there is some basic thing that I am missing about selectors. I would like to understand the basic concept behind this error as I have not found an general error reference.
I am getting this error when using:
[CloseButton addTarget:PageContents action:@selector(CloseButtonPressed) forControlEvents:UIControlEventTouchUpInside];
and then later:
- (void)CloseButtonPressed:(id)sender{
UIAlertView *someError = [[UIAlertView alloc] initWithTitle: @"Comment" message: @"hello" delegate: self cancelButtonTitle: @"Ok" otherButtonTitles: nil];
[someError show];
[someError release];
}
Upvotes: 0
Views: 494
Reputation: 96927
A couple suggestions that will help your code follow writing conventions used by all Objective C applications, and make your code more easily readable to others:
closeButton
and not CloseButton
, and pageContents
, not PageContents
-closeButtonPressed:
and not -CloseButtonPressed:
To answer your question, you need to fix the action you are adding:
[CloseButton addTarget:PageContents action:@selector(CloseButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
That colon character (:
) makes sure the sender
gets through to -CloseButtonPressed:
Upvotes: 3
Reputation: 170809
As CloseButtonPressed takes parameter you should create selector using: @selector(CloseButtonPressed:)
Upvotes: 0