Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Swift:if语句中的预期声明错误_Ios_Swift_Uiviewcontroller - Fatal编程技术网

Ios Swift:if语句中的预期声明错误

Ios Swift:if语句中的预期声明错误,ios,swift,uiviewcontroller,Ios,Swift,Uiviewcontroller,我有一个TableViewController和一个ViewController。我试图将两者链接在一起,并在ViewController中打印特定语句,具体取决于TableViewController中已标记的行 我声明了一个名为rowCounter的公共变量,并在TableViewController类中将rowCounter设置为等于indexPath的行 然后,在TableViewController中,我尝试使用if语句访问rowCounter变量并打印一条依赖于该数字的语句,但我不断

我有一个TableViewController和一个ViewController。我试图将两者链接在一起,并在ViewController中打印特定语句,具体取决于TableViewController中已标记的行

我声明了一个名为rowCounter的公共变量,并在TableViewController类中将rowCounter设置为等于indexPath的行

然后,在TableViewController中,我尝试使用if语句访问rowCounter变量并打印一条依赖于该数字的语句,但我不断收到一个“预期声明”错误。我做错了什么

代码如下:

TableViewController:

视图控制器:

在职能范围之外

在职能范围之外

import UIKit

var rowCounter: Int = 0

class TableTableViewController: UITableViewController {

override func viewDidLoad() {
    super.viewDidLoad()

    // Uncomment the following line to preserve selection between presentations
    // self.clearsSelectionOnViewWillAppear = false

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem()
}

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

override func tableView(tableView: UITableView, willSelectRowAtIndexPath indexPath: NSIndexPath) -> NSIndexPath? {

    rowCounter = indexPath.row

    return indexPath
}
import UIKit

class ViewController: UIViewController {

if rowCounter == 1 {

println("test")

}

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

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

}
if rowCounter == 1 {

println("test")

}