0
我试图在我的PasswordResetViewController上使用RACCommand
。在我viewDidLoad
我有以下几点:RACCommand混淆
sendButtonItem = UIBarButtonItem(title: "Reset Password", style: .Done, target: self, action: nil)
var emailIsValid = textField.rac_textSignal().map { text -> AnyObject! in
return count((text as! String)) > 0
}
let passwordResetSignal = RACSignal.createSignal { (subscriber) -> RACDisposable! in
User.requestPasswordResetForEmailInBackground(self.textField.text) { success, error in
if success {
subscriber.sendNext(success)
subscriber.sendCompleted()
} else {
subscriber.sendError(error)
}
}
return nil
}
sendButtonItem.rac_command = RACCommand(enabled: emailIsValid) { (input) in
return passwordResetSignal
}
sendButtonItem.rac_command.executionSignals.subscribeError { (error) -> Void in
println("ERROR!")
}
sendButtonItem.rac_command.executionSignals.subscribeNext { (success) -> Void in
println("SUCCESS!")
}
navigationItem.rightBarButtonItem = sendButtonItem
的rightBarButtonItem
启用/禁用如我所料,但我没有得到任何未来或错误事件。
感谢您的解释! –