Details
-
Feature Request
-
Resolution: Done
-
Major
-
None
-
None
-
None
-
None
Description
when using following snippet (as advice in readme):
let http = Http(baseURL: "http://server.com")
http.GET("/get", completionHandler: {(response, error) in
// handle response
})
http.POST("/post", parameters: ["key": "value"], completionHandler: {(response, error) in
// handle response
})
in one method called, task get cancelled. This is due to the deinit call:
https://github.com/aerogear/aerogear-ios-http/blob/master/AeroGearHttp%2FHttp.swift#L105
which occurs when http get released.
As advice in apple doc, releasing NSURLSession is important to prevent memory leak.
But in our case, we doing this releasing at the wrong place/moment.
workaround solution: only use http as instance variable of your ViewController
Possible ways forward:
- use singleton instance and make sure instance is not released until last callback is called, a la Alamofire
- remove deinit?