为什么rx.text / rx.observe / rx.etc不可用(RxSwift)

时间:2017-01-05 23:21:43

标签: swift rx-swift

我用Cocoapods创建了一个简单的项目并安装了RxSwift和RxCocoa。

我已经写了这段代码:

import UIKit
import RxSwift

class ViewController: UIViewController {

    @IBOutlet weak var field: UITextField!

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        //self.field.rx. (only suggests `base`)
    }

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


}

所以我应该能够self.field.rx.text正确吗?但我只得到self.field.rx.base

我错过了什么?

1 个答案:

答案 0 :(得分:5)

你必须在顶部添加import RxCocoa