我正在尝试使用Storyboard在Swift中创建一个应用程序。我想有一个按钮触发UIProgressView的动画。
*Expected '{' in body of function declaration*
import Cocoa
class ViewController: NSViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override var representedObject: AnyObject? {
didSet {
// Update the view, if already loaded.
}
}
@IBAction func PressKit(sender: AnyObject) {
func startAnimating()
}
}
答案 0 :(得分:0)
如果您尝试调用该功能" startAnimating",则不要使用" func"在它前面的关键字,只需使用" startAnimating()"调用该函数。然后,您需要定义该功能(在" PressKit"功能之外)。您可能希望在类中的其他位置执行此操作,例如:
func startAnimating() {
...some code...
}