alamofire

Bridge Swift to Objective-C library “ono” using cocoapods

风格不统一 提交于 2020-01-23 23:27:07
问题 For my swift iPhone app I'm needing to parse XML. I'm using Alamofire and trying to use Ono which is an objective c library. I used cocoapods to install Alamofire & Ono. I've followed the steps here: How to integrate Cocoapods with a Swift project? where I have #import <Ono/Ono.h> in my bridging header. Whats very odd is that in swift I can reference many of the Ono classes, but there is one function XMLDocumentWithData that I can't. E.g. HTMLDocumentWithString I can call, but

Unable to connect from IPv6 to IPv4 Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found

一世执手 提交于 2020-01-23 03:58:07
问题 I got the below error, while calling API from my iOS app (device) to server. My device is connected to IPv6 network & API which i am calling is with IPv4 network. I created the app using swift and i am using Alamofire for calling API and Reachability for checking Internet connection. What should i do for this. Please suggest on the below error. Request failed with error: Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo=

Realm: Map JSON to Realm-Objects with Alamofire

…衆ロ難τιáo~ 提交于 2020-01-22 21:24:59
问题 I would like to use Realm and Alamofire to map JSON to my database objects. Are there good tutorials out there? 回答1: Realm offers built-in limited capabilities of mapping arbitrary JSON structures to RLMObjects . But there are some good third-party libraries, which could assist you with your use-case. You might want to checkout these: Realm-JSON (Objective-C), which offers a declarative, Mantle like way of defining your mapping ObjectMapper (Swift), which offers Realm and Alamofire support 来源

Realm: Map JSON to Realm-Objects with Alamofire

走远了吗. 提交于 2020-01-22 21:21:36
问题 I would like to use Realm and Alamofire to map JSON to my database objects. Are there good tutorials out there? 回答1: Realm offers built-in limited capabilities of mapping arbitrary JSON structures to RLMObjects . But there are some good third-party libraries, which could assist you with your use-case. You might want to checkout these: Realm-JSON (Objective-C), which offers a declarative, Mantle like way of defining your mapping ObjectMapper (Swift), which offers Realm and Alamofire support 来源

How to send total model object as a parameter of Alamofire post method in Swift3?

那年仲夏 提交于 2020-01-22 14:51:10
问题 I have a model class like this class Example() { var name:String? var age:String? var marks:String? } I'm adding data to that model class let example = Example() example.name = "ABC" example.age = "10" example.marks = "10" After that I converted to JSON then I posted Alamofire.request(URL, method:.post, parameters: example) Alamofire not accepting parameters only its accepting like parameters = ["":"","",""]-->key value based , so I tried to convert model to JSON, JSON to dictionary, even

Alamofire.download() method: Where is the file and did it save successfully?

六眼飞鱼酱① 提交于 2020-01-22 05:53:05
问题 The example for using Alamofire.download() works just fine, but there isn't any detail in how to access the resulting downloaded file. I can figure out where the file is and what it was named based on the destination I set and the original file request I made, but I would assume that there is a value I should be able to access to get the full final download path and file name in the response. How do I access the name of the file and how do I know if it saved successfully? I can see delegate

How to pause/resume/cancel my download request in Alamofire

£可爱£侵袭症+ 提交于 2020-01-22 05:19:05
问题 I am downloading a file using Alamofire download with progress but i have no idea how to pause / resume / cancel the specific request. @IBAction func downloadBtnTapped() { Alamofire.download(.GET, "http://httpbin.org/stream/100", destination: destination) .progress { (bytesRead, totalBytesRead, totalBytesExpectedToRead) in println(totalBytesRead) } .response { (request, response, _, error) in println(response) } } @IBAction func pauseBtnTapped(sender : UIButton) { // i would like to pause

Swift 2.0 soap request with Alamofire send xml parameters

不打扰是莪最后的温柔 提交于 2020-01-21 07:17:28
问题 I want to do a request to this web service example: http://www.holidaywebservice.com//HolidayService_v2/HolidayService2.asmx?wsdl I need to send one parameter "countryCode". I don't know how can i do that with alamofire. And how i get the response to parse the xml result. This is how i did in postman, but i want to know how do the same in swift. Thanks for your help. 回答1: Try it Will make a POST request URL = http://holidaywebservice.com/HolidayService_v2/HolidayService2.asmx?wsdl The

How to retrieve Alamofire response header for a request

我们两清 提交于 2020-01-20 03:50:37
问题 how can I retrieve response headers for a request? Below is a request I make. Alamofire.request(.GET, requestUrl, parameters:parameters, headers: headers) .responseJSON { response in switch response.result { case .Success(let JSON): ... case .Failure(let error): ... } Thanks in advance! 回答1: If the response is type of NSHTTPURLResponse you can get header from response.allHeaderFields . So when you use Alamofire responseJSON you can access to NSHTTPURLResponse property like this : Alamofire

PDF File reading Issue only on Offline mode swift

天涯浪子 提交于 2020-01-16 09:59:17
问题 I have successfully Implemented downloading mechanism for pdf files. Files are downloading and save to document directory of simulator. Issue is when I try to disconnect internet the files locally stored not accessible. In my application I have two modes Online and Offline. In Online mode I store data and its accessible at Offline mode. Only problem is getting with pdf files. How to access pdf files in offline mode? viewController Code: let fileType = (URL != nil) ? ".pdf" : ".png"