0
votes

I'm trying to implement pull-to-refresh for my UITableView in iOS. The implementation is nearly done except that I can't properly perform the action that will take place for the refresh operation.

    [self.refreshControl addTarget:self
                        action:(SEL)[self performSelector:@selector(fetchPhotoListWith:Using:)
                                          withObject:@"https://api.instagram.com/v1/users/self/feed?access_token="
                                          withObject:@"<my Instagram ID>"]
              forControlEvents:UIControlEventValueChanged];

The above code(initiated in viewDidLoad) gives the following error:

Cast of an Objective-C pointer to 'SEL' is disallowed with ARC

If I remove the (SEL) casting in the front, this time I get the following error:

Implicit conversion of an Objective-C pointer to 'SEL' is disallowed with ARC

with another warning:

Incompatible pointer types sending 'id' to parameter f type 'SEL'

How can I play nice with ARC while being able to call my method with two arguments?

1

1 Answers

4
votes

That isn't how target/action works, you need to pass it a selector that is one of the forms that it lists in the documentation.

You should do something like:

[self.refreshControl addTarget:self action:@selector(refresh) forControlEvents:UIControlEventValueChanged];

And then make the refresh method call your method to refresh that data:

- (void)refresh {
    [self fetchPhotoListWith:@"https://api.instagram.com/v1/users/self/feed?access_token="
                       using:@"<My Instagram API Token>"];
}