我不明白我的View Controller中這段代碼有什麼問題,底線(帶有單個括號)會一直出現兩個錯誤,一個聲明「連續聲明行必須用';'「和」預期聲明「分隔。當我將分號添加到它指向的地方時,它仍然會說預期的聲明錯誤....但是對於什麼?任何人都可以找到它的任何錯誤?有關在一條線上連續聲明的Swift錯誤
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
var testObject = PFObject(className:"TestObject")
testObject["foo"] = "bar"
testObject.saveInBackgroundWithTarget(nil, selector: nil)
var voteCount = PFObject(className:"VoteCount")
voteCount["votes"] = 0
voteCount["optionName"] = "Crepes"
voteCount.incrementKey("votes")
voteCount.saveEventually()
var query = PFQuery(className:"VoteCount")
query.getObjectInBackgroundWithId("e8KhneiSfw") {
(voteCount: PFObject!, error: NSError!) -> Void in
if error != nil {
NSLog("%@", error)
} else {
voteCount["votes"] = 1
voteCount.incrementKey("votes")
voteCount.saveEventually()
}
}
class Counter {
var voteCount: Int = 0
func incrementBy(amount: Int, numberOfTimes times: Int) { voteCount += amount * times
}
}
func didReceiveMemoryWarning() {
didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
這樣做的伎倆,謝謝! – appyhour 2014-10-31 20:57:54