alamofire

what is the advantage of using Alamofire over NSURLSession/NSURLConnection for networking?

烈酒焚心 提交于 2019-12-06 16:57:04
问题 Can anyone help me in understanding these question : What is the advantage of using Alamofire over NSURLSession/ NSURLConnection? What are the differences between NSURLSession and NSURLConnection? 回答1: NSURLConnection is Apple's old API for doing networking (e.g. making HTTP requests and receiving responces), while NSURLSession is their new one. The latter one is higher level and is generally much easier and involves less boilerplate code to use for most application developers - there's

Use 3rd party pod in sub-project (framework project)

a 夏天 提交于 2019-12-06 15:54:07
问题 I am using XCode 8 + Swift 3. I created a fresh iOS project named " MyApp ". Then, I create a Cocoa touch framework project, named "MySubProject". (The idea is to have MyApp project accessing MySubProject code.) They are on the same level folder: - MyApp/ - MySubProject/ I added MySubProject into MyApp project, linked the MySubProject framework. Everything works fine. My project structure looks like this: All works until here! (MyApp code can access MyService code) Now, I need MySubProject to

API JSON & UIPageViewController optional Nil

强颜欢笑 提交于 2019-12-06 15:50:25
问题 Okay, I am trying to work out a pageview slider that retrieves images url from an API using this tutorial as a base. I have already coded the asynchronous downloading of images and appending it to the pageImages array. That part works fine. However, I received an error when I am trying to run the app in the simulator : fatal error: unexpectedly found nil while unwrapping an Optional value For some reason, fetching the JSON objects and populating the pageImages Array happens after I call my

Alamofire and SwiftyJSON for Swift 2.0

ε祈祈猫儿з 提交于 2019-12-06 12:18:50
I am updating my code for Swift 2.0 for today, however the line var json = JSON(json) gives me the following error Cannot invoke intializer for type 'JSON' with an argument list of type (Result) Do you guys have any idea how should I change my code? @IBAction func changePassword(sender: UIBarButtonItem) { Alamofire.request(.POST, AppDelegate.kbaseUrl + "users/me/password", parameters: ["old_password": self.oldPasswordTextField.text!, "new_password": self.newPasswordTextField.text!, "confirm_password": self.confirmPasswordTextField.text!], encoding: .JSON) .responseJSON { (req, res, json) in

GoogleDrive + Alamofire: Uploading a file with properties

我的梦境 提交于 2019-12-06 11:29:22
I am trying to upload a file + parameters to Google Drive via Swift 2/Alamofire. In the code below, i I change the line that says: "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart" to the following: "https://www.googleapis.com/upload/drive/v3/files" the file uploads to google without a name. Otherwise, the file upload fails with the same generic code: Error Domain=com.alamofire.error Code=-6003 "Response status code was unacceptable: 400" UserInfo={NSLocalizedFailureReason=Response status code was unacceptable: 400} I'd like to be able to upload the file with name and

Alamofire4 trouble with JSONResponseSerializer & HTTPURLResponse Swift 3.0

我是研究僧i 提交于 2019-12-06 10:29:17
Since I updated Alamofire I get the errors: Type Request has no member JSONResponseSerializer and cannot call value of non-function type HTTPURLResponse I have already switched Response to DataResponse but I still get the error. Code: extension Alamofire.Request { func responseUserEventsArray(_ completionHandler: @escaping (DataResponse<UserEventsWrapper>) -> Void) -> Self { let responseSerializer = DataResponseSerializer<UserEventsWrapper> { request, response, data, error in guard error == nil else { return .failure(error!) } guard let responseData = data else { return .failure(AFError

Using a value from Alamofire request outside the function

泪湿孤枕 提交于 2019-12-06 09:48:37
I can't seem to figure this one out: I am trying to get an error from my server (in JSON) using an Alamofire request, but I cannot get the value outside the function. This is the implementation of my function: func alamoRequest(username : String, email: String, password: String, facebook: String, completionHandler : (String?) -> Void) { var jsonValue : JSON? let URL = "http://someurl.com/login.php" let requestParameters = ["username" : username, "email" : email, "password" : password, "facebook" : facebook, "date": NSNull()]; var jsonString : String = String() Alamofire.request(.GET, URL,

Swift - multiple Chain http request with loop

霸气de小男生 提交于 2019-12-06 09:32:01
Since 2 days it feels that I'm searching the whole web to solve my problem with multiple http requests. So my workflow looks like this: Upload a image to a server Response = XML Format with a Task ID GET request to the server with the Task ID to check the status of this task. Response = XML Format where the status could be "Completed", "In Progress", "Queued" If Status != "Completed" - retry step 2 If Status == "Completed" - go to step 3 Download the result from the resultUrl My last try was to use PromiseKit to chain the requests in a clean way like described in this post: Chain multiple

UIProgressView progress update very slow within AlamoFire (async) call

不问归期 提交于 2019-12-06 09:25:50
问题 Inside an AlamoFire get request I'm trying to update my progress bar. Like so: alamofireManager.request(.GET, urlPath, parameters: params).responseJSON{(request,response,JSON,error) in ...<code here>... dispatch_async(dispatch_get_main_queue(), { NSNotificationCenter.defaultCenter().postNotificationName(LoginVCHideSpinnerAndShowProgressBarName as String, object: self) }) ...<more code here>... } For some reasons this takes a few seconds to execute and if I use dispatch_sync instead the app

iOS: (Swift) How to show distance from current location and exist annotation on annotation subtitle

五迷三道 提交于 2019-12-06 08:44:42
问题 I am currently working on map application base on iOS using Swift language. I would like an suggestion because after I plot all the pins on map view (which I receive data from my server using JSON frameworks call Alamofire) I would like the subtitle of all annotations on map to show distance from user current location. Now it can add annotations onto map view but can only show title and subtitle base on information receive from my server. Thank You. 回答1: If you have two CLLocation instances,