0
我在我的ViewModel中有這個功能,它返回一個信號,但裏面的塊不工作,我試圖添加斷點,但它不會中斷。這是我的代碼。反應可可信號不工作
func executeLoginAPI() -> RACSignal {
var sessionDataTask: NSURLSessionDataTask = NSURLSessionDataTask()
return RACSignal.createSignal({
(subscriber: RACSubscriber!) -> RACDisposable! in
//I've added break point here but it doesn't break.
let manager: APIManager = APIManager.sharedInstance
let parameters: NSDictionary = ["email": self.email, "password": self.password]
sessionDataTask = manager.POST(APIAtlas.loginUrl, parameters: parameters, success: {
(task: NSURLSessionDataTask!, responseObject: AnyObject!) in
print(responseObject as! NSDictionary)
subscriber.sendNext(responseObject)
subscriber.sendCompleted()
}, failure: {
(task : NSURLSessionDataTask!, error: NSError!) in
/*if let task = task.response as? NSHTTPURLResponse {}*/
})!
let dispose: RACDisposable = RACDisposable(block: {
print("cancel request!")
sessionDataTask.cancel()
subscriber.sendCompleted()
})
return dispose
})
}
我訪問它在我的viewController這樣
self.signInViewModel.executeLoginAPI()
請給我一隻手。謝謝!