You didn't set the action for the refresh control. Try this instead:
-(void) viewDidLoad
{
[super viewDidLoad];
UIRefreshControl *refreshControl = [UIRefreshControl new];
[refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];
refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull to refresh..."];
self.refreshControl = refreshControl;
}
- (void)refresh:(UIRefreshControl *)sender
{
// ... your refresh code
NSURL *url = [NSURL URLWithString:@"http://www.apinae.com/json.php"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
[sender endRefreshing];
}
Well, the call to -endRefreshing
should be in the delegate method so it stops refreshing when the file is downloaded and refreshed in the table, but you get the idea.