I'm using Alamofire to send HTTP request in my App. I'm using a TabBarViewController, In first view's ViewDidLoad, I send a request. Also in ViewWillDisappear, I send another request. However, I found it behave unexpected when I changing the tabs.
func sendHttpCommand(parameter: NSDictionary) {
Alamofire.request(.GET, URL, parameters: (parameter as! [String: AnyObject]))
.response {
request, response, data, error in
print(request)
}
}
viewDidLoad() {
let dict: NSDictionary = ["value": 0]
sendHttpCommand(dict)
}
viewWillDisappear(animated: Bool) {
let dict: NSDictionary = ["value": 1]
sendHttpCommand(dict)
}
When I switching the tabs, in NORMAL CASE, my console will print out
Optional(NSMutableURLRequest {URL: xxxxx/value=0})
Optional(NSMutableURLRequest {URL: xxxxx/value=1})
Optional(NSMutableURLRequest {URL: xxxxx/value=0})
Optional(NSMutableURLRequest {URL: xxxxx/value=1})
Optional(NSMutableURLRequest {URL: xxxxx/value=0})
Optional(NSMutableURLRequest {URL: xxxxx/value=1})
Optional(NSMutableURLRequest {URL: xxxxx/value=0})
Optional(NSMutableURLRequest {URL: xxxxx/value=1})
However, when I switching the tabs fast enough, my console will print out
Optional(NSMutableURLRequest {URL: xxxxx/value=0})
Optional(NSMutableURLRequest {URL: xxxxx/value=1})
Optional(NSMutableURLRequest {URL: xxxxx/value=1})
Optional(NSMutableURLRequest {URL: xxxxx/value=0})
Optional(NSMutableURLRequest {URL: xxxxx/value=0})
Optional(NSMutableURLRequest {URL: xxxxx/value=1})
Optional(NSMutableURLRequest {URL: xxxxx/value=1})
Optional(NSMutableURLRequest {URL: xxxxx/value=0})
Any ideas?