Skip to content

Instantly share code, notes, and snippets.

@ben-ng
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ben-ng/65bdbce3e5af82e11a21 to your computer and use it in GitHub Desktop.
Save ben-ng/65bdbce3e5af82e11a21 to your computer and use it in GitHub Desktop.
@implementation MainViewController {
NSURLSession *_session;
}
- (void) doSomethingElse
{
[self doSomethingWithCompletionHandler: ^(){
// create session.. add download tasks..
// _session = blah blah
// _session.createDownloadTask etc
[self performSelector:@selector(cancel) withObject: nil afterDelay: 1];
}];
}
- (void) cancel
{
if(_session) {
[_session invalidateAndCancel];
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment