Skip to content

Instantly share code, notes, and snippets.

@jweinberg
Created April 30, 2015 01:22
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 jweinberg/e330a7a5fb7ed651e263 to your computer and use it in GitHub Desktop.
Save jweinberg/e330a7a5fb7ed651e263 to your computer and use it in GitHub Desktop.
__block id foo = [self funcReturningHandle:^{
[weakSelf removeHandle:foo];
}]
@lilyball
Copy link

Assuming

func funcReturningHandle() -> AnyObject { /* ... */ }
func removeHandle(_: AnyObject) { /* ... */ }

I'd suggest

var foo: AnyObject!
foo = funcReturningHandle({ [weak self] in
    self?.removeHandle(foo)
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment