0

I have the following code for my pull-to-refresh "feature" (refreshing a CollectionView

UIRefreshControl *refreshControl = UIRefreshControl.alloc.init;
[refreshControl addTarget:self action:@selector(startRefresh:)
         forControlEvents:UIControlEventValueChanged];
[self.collectionView addSubview:refreshControl];

However, this will crash my app with the following error message:

[CollectionViewController startRefresh:]: unrecognized selector sent to instance 0x7543610
2013-03-24 12:20:10.049 

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CollectionViewController startRefresh:]: unrecognized selector sent to instance 0x7543610'

What am I missing here? Thanks!

schnabler
  • 687
  • 7
  • 23

1 Answers1

1

Make sure your startRefresh: method takes an argument, that's what the colon in @selector(startRefresh:) means. The error that you are getting means that it cannot find the method and execute it.

To know what a selector is and the correct way to implement the target-action pattern, I recommend you to take a look at the docs, here and here.

Fran Sevillano
  • 8,103
  • 4
  • 31
  • 45
  • thanks for your answer, but I still wouldn't know how to fix it. i'm not too familiar with @selectors. can you elaborate some more? thank you. – schnabler Mar 24 '13 at 12:15
  • thanks. i think this helped, but now i'm running into more problems. (as you can see above). quite sure, this is somewhat more tricky than an ios rookie like me can handle ;) – schnabler Mar 24 '13 at 14:26