我有点误解如何在swift中正确使用 - (void).每当我尝试使用 - (Void)编写代码但我收到错误" Expected declaration"或有时" Binary operator '-' cannot be applied to operands of type 'UIFont' and '(Void).Type'".
为什么会这样?在swift中正确使用此功能的正确方法是什么?
{
- (Void)keyboardWillShow { //>> showing me the error "Binary operator '-' cannot be applied to operands of type 'UIFont' and '(Void).Type'"
// Animate the current view out of the way
if (self.view.frame.origin.y >= 0)
{
[self setViewMovedUp:YES];
}
else if (self.view.frame.origin.y < 0)
{
[self setViewMovedUp:NO];
}
}
Run Code Online (Sandbox Code Playgroud)
}
谢谢
小智 5
听起来你正试图声明一个没有返回值的函数.在Swift中,这可以做到:
func thisFunction() {
..
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
780 次 |
| 最近记录: |