【发布时间】:2014-09-02 13:12:27
【问题描述】:
这是objective-c中的代码:
[self presentViewController:logInViewController animated:YES completion:NULL];
到目前为止,我的代码在 swift 中:
self.presentViewController(logInViewController, animated: true, completion: )
认为它就像输入“Void”一样简单。不幸的是,还有更多内容。
【问题讨论】:
-
nil不行吗? -
@KevinDiTraglia 最初尝试但没有成功,但现在我可以看到这是一个自动完成问题。 XCode 6 中的自动完成功能有点古怪。还没习惯。
-
你应该为 Swift and Objective C 使用 nil。这很明智,并且很容易记住......
-
但是,
nil只能在完成块是可选的情况下使用。在这种特定情况下(可能在大多数 UIKit 情况下)该块被调用为(()->Void)!,因此它是一个显式解包的可选并且取 nil。
标签: objective-c swift objective-c-blocks