Created
January 22, 2015 00:54
-
-
Save cdzombak/431cea0a4c0ced8042a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
}) | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 returnVoid
, 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, returnVoid
.