2015-07-04 34 views
0

我試圖在iOS中爲我的UITableView實現拉到刷新。除了我無法正確執行刷新操作將執行的操作之外,該實現幾乎完成。鑄造一個Objective-C指向'SEL'的指針不允許使用ARC

[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]; 

(在viewDidLoad啓動),上面的代碼提供了以下錯誤:

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

如果我在前面取下(SEL)鑄造,這次我得到以下錯誤:

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

另一個警告:

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

如何在用兩個參數調用我的方法的同時與ARC玩好?

回答

4

這不是目標/操作的工作方式,您需要將它傳遞給選擇器,它是文檔中列出的一種形式。

你應該這樣做:

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

然後進行刷新方法調用你的方法來刷新數據:

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