-1

I have a UITableViewController in which I am implementing a UIRefreshControl for pull to refresh. Everything is working fine, the table is getting populated from my web service. But when I pull down to refresh I get the error:

[MyViewController refreshView]: unrecognized selector sent to instance ...

Which is complaining about the addTarget action here:

UIRefreshControl * refresh = [[UIRefreshControl alloc] init];
[refresh addTarget:self action:@selector(refreshView) forControlEvents:UIControlEventValueChanged];

The error flag on that line in the editor is Undeclared selector 'refreshView'

My refreshView method is simply:

- (void) refreshView: (UIRefreshControl *)refresh { 
    NSLog(@"test");
}

Any ideas as to why this would be causing the application to crash? (I am running iOS 7.1)

Brett Gregson
  • 5,867
  • 3
  • 42
  • 60

1 Answers1

6

If you declared your method as "refreshView:" (i.e. with a parameter), you need to add a colon to the "@selector" bit.

In other words, one line changes with one character:

[refresh addTarget:self action:@selector(refreshView:) forControlEvents:UIControlEventValueChanged];
Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215