Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class Router : NSObject {
typealias VCPushBlock = (UIViewController) -> (Void)
init(context: NSManagedObjectContext, pushBlock: VCPushBlock) {
// ...
}
convenience init(context: NSManagedObjectContext, owningViewController: UIViewController) {
self.init(context: context, pushBlock: {
owningViewController.navigationController?.pushViewController($0, animated: true)
return Void()
})
}
// ...
}
@cdzombak

This comment has been minimized.

Copy link
Owner Author

commented Jan 22, 2015

Note that line 11 has changed to an explicit return Void() (instead of the comment with the compiler's error message).

The optional method chaining on line 10 was returning a Void?, as it should. And though I always intended the block to return Void, this was a single-line block, so its inferred return type was that of its one line: Void?.

Adding the explicit return Void() allows the compiler to infer that the block does, in fact, return Void.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.