如何使类中的变量像参考值一样?

时间:2016-02-21 14:07:46

标签: ios xcode swift

现在我正在创建一个类,该类有变量,以下是示例(只是一个不太严重的例子)

class NewGroupCell2TableViewCell: UITableViewCell,UITextFieldDelegate {

var customSearchBarController:CustomSearchController!
@IBOutlet weak var sortByButton: UIButton!
@IBOutlet weak var hashTagTextField: UITextField!
var testingString:String!

}

但是当我创建这个类时,我将变量的值传递给类。所以就像

let cell2 = tableView.dequeueReusableCellWithIdentifier("cell2", forIndexPath: indexPath) as! NewGroupCell2TableViewCell
                cell2.customSearchBarController = customSearchController
                cell2.testingString = testingString

但是,在调用NewGroupCell2TableViewCell的类上,有一个testingString变量,我期待它,当NewGroupCell2TableViewCell中的事件改变了testsString的值时,testsString的外部类变量可以在事件发生时改变NewGroupCell2TableViewCell更改了testingString值。我怎么能让变量引用内部类和外部类?

请注意,inout函数只能在函数类上使用。

0 个答案:

没有答案
相关问题