如果swift中的语句返回有关花括号的错误

时间:2015-02-01 19:52:12

标签: swift xcode6

我有一个我最近修复的if语句,但现在而不是过去的错误(请参阅我最近的问题),我收到此错误:

Braced block of statements is an unused closure

这是我的代码:

import UIKit

class DAGNConfirmViewController: UIViewController {
    @IBOutlet weak var DValueLabel: UILabel!
    @IBOutlet weak var AValueLabel: UILabel!
    @IBOutlet weak var GValueLabel: UILabel!
    @IBOutlet weak var NValueLabel: UILabel!
    @IBOutlet weak var TValueLabel: UILabel!
    @IBOutlet weak var ErrorField: UILabel!

    let nf = NSNumberFormatter()
    let DAGNViewControllerInstance: DAGNViewController = DAGNViewController()

    @IBAction func YESButtonPressed(sender: UIButton) { }

    @IBAction func NOButtonPressed(sender: UIButton) { }

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.    

        DValueLabel.text = nf.stringFromNumber(DAGNViewControllerInstance.DValueVar)
        AValueLabel.text = nf.stringFromNumber(DAGNViewControllerInstance.AValueVar)
        GValueLabel.text = nf.stringFromNumber(DAGNViewControllerInstance.GValueVar)
        NValueLabel.text = nf.stringFromNumber(DAGNViewControllerInstance.NValueVar)
        TValueLabel.text = nf.stringFromNumber(DAGNViewControllerInstance.TValueVar)

        // If statement here
        if !(DAGNViewControllerInstance.DValueVar <= 5) ||
           !(DAGNViewControllerInstance.DValueVar >= 1) ||
           !(DAGNViewControllerInstance.AValueVar <= 6) ||
           !(DAGNViewControllerInstance.AValueVar >= 2) ||
           !(DAGNViewControllerInstance.GValueVar <= 3) ||
           !(DAGNViewControllerInstance.GValueVar) >= 2 ||
           !(DAGNViewControllerInstance.NValueVar <= 3) ||
           !(DAGNViewControllerInstance.NValueVar >= 1) ||
           !(DAGNViewControllerInstance.TValueVar <= 9999) ||
           !(DAGNViewControllerInstance.TValueVar >= 1) {
            self.ErrorField.text = "One or more values are not in range!"
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}

为什么会这样,我该如何解决?我不认为我错过了一个大括号。此错误是否与花括号的位置有关?

1 个答案:

答案 0 :(得分:1)

你写的是:

!(DAGNViewControllerInstance.GValueVar) >= 2

应该是:

!(DAGNViewControllerInstance.GValueVar >=2 )