Hi i currently have embedded tableview in UIViewController. In the tableview i have collection of json data. I wish to make a refresh controller, so whenever the user pulls down, the json data is refreshed.
I have tried the following code
- (void)viewDidLoad
{
[superviewDidLoad];
UIRefreshControl *refreshControl = [[UIRefreshControl alloc]
init];
[refreshControl addTarget:nil action:@selector(updateArray) forControlEvents:UIControlEventValueChanged];
self.refreshControl = refreshControl;
}
-(void) updateArray{
[self.tableView reloadData];
[self.refreshControl endRefreshing];
}
I am getting an error which says property refreshControl not found in ViewController.
Is it because i am using embedded tableview or am i doing something wrong?
You are instantiating the UIRefreshControl inside the viewDidLoad method. The reference to that object is not visible to the updateArray method. You will need to either make it a property or a instance variable.
@property (strong, nonatomic) UIRefreshControl *refreshControl;
then instead of
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
use
refreshControl = [[UIRefreshControl alloc] init];