Skip to content

Instantly share code, notes, and snippets.

@juliengrimault
Created May 14, 2012 08:48
Show Gist options
  • Select an option

  • Save juliengrimault/2692793 to your computer and use it in GitHub Desktop.

Select an option

Save juliengrimault/2692793 to your computer and use it in GitHub Desktop.
Retain cycle in MKNetworkOperation completion handler
- (void)viewDidAppear:(BOOL)animated
{
self.operation = [ApplicationDelegate.flickrEngine imagesForTag:@"Singapore"
onCompletion:^(NSMutableArray* images)
{
self.flickrImages = images; //retain cycle here
[self.tableView reloadData];//retain cycle here
}
onError:^(NSError* error) {
}];
}
- (void)viewDidAppear:(BOOL)animated
{
__weak FlickrTableViewController weakSelf = self; //to prevent retain cycle
self.operation = [ApplicationDelegate.flickrEngine imagesForTag:@"Singapore"
onCompletion:^(NSMutableArray* images)
{
weakSelf.flickrImages = images;
[weakSelf.tableView reloadData];
}
onError:^(NSError* error) {
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment