alamofire

Linker Error After Updating swift Version and pods

久未见 提交于 2019-12-12 15:18:29
问题 I am installing Alamofire with pods and getting compile time error. There are a lot of questions regarding this but: Deleting the derived data & updating pods won't work for me. This is the error: Alamofire/Alamofire.framework/Alamofire compiled with newer version of Swift language (3.0) than previous files (2.0) for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) 回答1: Update following things in your pod files: source 'https://github.com

iOS - Alamofire v2 Basic Auth not working

☆樱花仙子☆ 提交于 2019-12-12 13:08:12
问题 So I'm sending a basic auth request to Bing Image Search to grab some image data, and it was working great, right until I updated to the latest version of Alamofire (1.3 -> 2.0.2), which I had to do because 1.3 wasn't even close to compatible with XCode 7. Anyway, here is my code: let credentials = ":\(Settings.bingApiKey)" let plainText = credentials.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) let base64 = plainText!.base64EncodedStringWithOptions

Upload files using multipart request - Swift 4

情到浓时终转凉″ 提交于 2019-12-12 09:58:45
问题 I have to upload files on server using multipart request. For network calls i am using Alamofire. What i have done so far is below Request Service: Multipart request:- let headers: HTTPHeaders = [ "Content-type": "multipart/form-data" ] let fileData = Filedata() // getting data from local path let URL = try! URLRequest(url: "https://SomeUrl/upload", method: .post, headers: headers) Alamofire.upload(multipartFormData: { (multipartFormData) in //multipartFormData.append(fileData, withName:

Swift Alamofire send XML request and receive XML response

北战南征 提交于 2019-12-12 05:45:08
问题 Hi i'm making a move from Objective C to swift. I'm trying to send xml request and receive xml response. How we can do that with Alamofire. Seem only can do for JSON? my end point: "https://prdesb1.singpost.com/ma/GetItemTrackingDetails" my sample request body (xml) : <ItemTrackingDetailsRequest xmlns="http://singpost.com/paw/ns"> <ItemTrackingNumbers> <TrackingNumber>SMT0000000628</TrackingNumber> </ItemTrackingNumbers> </ItemTrackingDetailsRequest> The response should be

Post request error with parameter encode when use moya and alamofire

杀马特。学长 韩版系。学妹 提交于 2019-12-12 05:42:00
问题 I use the moya make the post request,but when I send the post , the server give me an error, it can't decoding the body parameters.I use URLEncoding.default to encode the parameters like this public var parameterEncoding: ParameterEncoding { return URLEncoding.default } It will set the content-type application/x-www-form-urlencoded, and the server accept content type is same too if parameters is a dictionary like this {"a":"b"} ,that is working well, but if dictionary contained array or

Display alert from a non-UI class

ぐ巨炮叔叔 提交于 2019-12-12 04:44:35
问题 I'm using Alamofire in my application and wish to display an alert if the request has an error (e.g. wrong URL), etc. I have this function in a separate class as it is shared among the pages of the application. Alamofire.request(.GET, api_url) .authenticate(user: str_api_username, password: str_api_password) .validate(statusCode: 200..<300) .response { (request, response, data, error) in if (error != nil) { let alertController = UIAlertController(title: "Server Alert", message: "Could not

Issue with uploading an image using Alamofire(has image as a parameter)

一世执手 提交于 2019-12-12 04:42:56
问题 This is how I am trying to upload an image using Alamofire. But the program crashes saying something like... 'NSInvalidArgumentException', reason: '-[_SwiftTypePreservingNSNumber dataUsingEncoding:]: unrecognized selector sent to instance... I'm not able figure the exact reason.This is how I'm making the request... for i in 1...(imageArray.count) { for img in imageArray { let url = "http://myapp.com/a/images_upload" let headers = [ "Content-Type":"application/x-www-form-urlencoded"] let

Get value from array objects with AlamofireObjectMapper/ObjectMapper (swift - iOS)

自闭症网瘾萝莉.ら 提交于 2019-12-12 04:35:52
问题 I'm new with this mapper thing and too confused. I have an API request, given a Title, the API return this: { Response = True; Search = ( { Poster = "https://images-na.ssl-images-amazon.com/images/M/MV5BMjAxODQ2MzkyMV5BMl5BanBnXkFtZTgwNjU3MTE5OTE@._V1_SX300.jpg"; Title = ARQ; Type = movie; Year = 2016; imdbID = tt5640450; }, { Poster = "N/A"; Title = Arq; Type = movie; Year = 2011; imdbID = tt2141601; }, { Poster = "N/A"; Title = "A.R.Q."; Type = movie; Year = 2015; imdbID = tt3829612; } );

How to get partial file path after downloading with Alamofire?

a 夏天 提交于 2019-12-12 04:33:54
问题 I want to save the path of where I downloaded a file to my model object. Based on this StackOverflow answer, I should "only store the filename, and then combine it with the location of the documents directory on the fly". Well in my case it's the Application Support directory. I am not sure how to do this. The full path of where the file will be downloaded is: /Library/ApplicationSupport/com.Company.DemoApp/MainFolder/myFile.jpg /Library/Application Support/ is the part I can't save anywhere

Managing asynchronous calls to web API in iOS

天涯浪子 提交于 2019-12-12 04:15:59
问题 I am fetching data (news articles) in JSON format from a web service. The fetched data needs to be converted to an Article object and that object should be stored or updated in the database. I am using Alamofire for sending requests to the server and Core Data for database management. My approach to this was to create a DataFetcher class for fetching JSON data and converting it to Article object: class DataFetcher { var delegate:DataFetcherDelegate? func fetchArticlesFromUrl(url:String,