绑定UITextField以查看模型变量

时间:2017-09-07 16:20:25

标签: ios swift swiftbond

我正在尝试使用Bond将UI元素绑定到我的视图模型。当我尝试将searchTextField绑定到我的视图模型searchString时,Xcode 8.3.3在调用中给出了一个“不正确的参数标签(具有':',期望'信号:')”错误。有什么问题?

import UIKit
import Bond
import ReactiveKit

class SearchViewModel {
   let searchString = Observable<String>("")
}

class SearchViewController: UIViewController {

   @IBOutlet weak var searchTextField: UITextField!

   let viewModel = SearchViewModel()

   override func viewDidLoad() {
      super.viewDidLoad()
      bindToViewModel()
   }

   func bindToViewModel() {
      searchTextField.reactive.text.bind(to: viewModel.searchString)
   }
}

1 个答案:

答案 0 :(得分:0)

问题在于:

import tensorflow as tf
x = tf.placeholder(tf.float32, [None, 784])

#layer 1
W1 = tf.Variable(tf.zeros([784, 100]))
b1 = tf.Variable(tf.zeros([100]))
y1 = tf.matmul(x, W1) + b1 #remove softmax

#layer 2
W2 = tf.Variable(tf.zeros([100, 10]))
b2 = tf.Variable(tf.zeros([10]))
y2 = tf.nn.softmax(tf.matmul(y1, W2) + b2)

#output
y = y2
y_ = tf.placeholder(tf.float32, [None, 10])

需要:

let searchString = Observable<String>("")

因为let searchString = Observable<String?>("") 需要一个可选的3stud1ant3指出。