alamofire

Alamofire returns wrong encoding

耗尽温柔 提交于 2019-12-07 06:50:50
问题 I`m using Alamofire.request(.GET, "http://") .responseString { _, _, string, _ in println(string) } to make get-request. Response contains сyrillic symbols and in responseString they looks like this (top-right): How should I fix encoding? 回答1: You can use NSUTF8StringEncoding with Alamofire's responseString method: Alamofire.request(.GET, "http://my1test.ru/applejesus.php?task=getCategory&categoryNumber=1") .responseString(encoding: NSUTF8StringEncoding) { (request, response, string, error) -

How to Set requestSerializer in Alamofire

安稳与你 提交于 2019-12-07 06:13:39
问题 I am currently working on a project in swift . I used Alamofire for REST API but to make it work i need to pass a parameter in requestSerializer In AFNETWORKING AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.requestSerializer = [AFJSONRequestSerializer serializer]; But i can't find anything for Alamofire . I'm new to swift please help me out. 回答1: You can pass pass JSON data as encoding parameters, Encoding in Alamofire is equivalent to

Showing JSON data on TableView using SwiftyJSON and Alamofire

北战南征 提交于 2019-12-07 04:44:10
问题 I want to show the JSON data grabbed from a server on a Table View. The problem is, I can't get it to show up on it. I have tried several different methods and searched a lot to find a solution, but I can't. My code (all of it) is shown below and I hope somebody can help me out. Thanks in advance. import UIKit import Alamofire import SwiftyJSON class MasterViewController: UITableViewController { var tableTitle = [String]() var tableBody = [String]() override func viewDidLoad() { super

Could not cast value of type '__NSArrayI' (0x10df73c08) to 'NSDictionary' (0x10df74108)

梦想与她 提交于 2019-12-07 03:52:24
问题 let url = "http://xyz/index_main.php?c=webservices&a=get&e=007" Alamofire.request(url, method: .post, parameters: nil, encoding: JSONEncoding.default) .responseJSON { response in print(response) //to get status code if let status = response.response?.statusCode { switch(status){ case 201: print("example success") default: print("error with response status: \(status)") } } //to get JSON return value if let result = response.result.value { let JSON = result as! NSDictionary print(JSON) } Result

swift 2.1 alamofire timeout method

爷,独闯天下 提交于 2019-12-07 03:22:31
问题 i have question about alamofire timeout methods, first of all , my english may not be good enough to let you guys to understand what i said... but i will tired to explain my question in my project, i used alamofire , for some reason , i need to make sure my app working of poor connection area. so i am thinking using timeout method. i saw there are some people said , use Solution 1: let configuration = NSURLSessionConfiguration.defaultSessionConfiguration() configuration

“Cannot call value of non-function type 'HTTPURLResponse?'” (Alamofire 4.0) [Swift 3.0]

柔情痞子 提交于 2019-12-07 03:17:53
问题 I'm receiving this error: "Cannot call value of non-function type 'HTTPURLResponse?'" on the section: .response { (request, response, data, error) and I was wondering if anyone can help me with this. Alamofire.download(urlToCall, method: .get) { temporaryURL, response in if FileManager.default.fileExists(atPath: finalPath!.path!) { do { try FileManager.default.removeItem(atPath: finalPath!.path!) } catch { // Error - handle if required } } return finalPath! } .response { (request, response,

Image passed from an API not displaying in a pageview container swift

情到浓时终转凉″ 提交于 2019-12-07 01:40:35
问题 I am working on an iOS application which interacts with an API using alamofire and swiftyJSON. In this api I get a bunch of values returned and one of them is images. the Images returned comes in form of an array but i am able to iterate through the array and display a single image. To make the application more advanced, I decided to implement UIPageViewController class in my application. I called the API function and tried to pass my images into view controllers. List of things in my

Alamofire framework not found

[亡魂溺海] 提交于 2019-12-06 20:57:52
问题 I am trying to install alamofire into my project so I can upload images to my server, however I cannot seem to find the alamofire.framework file. I have downloaded the git twice, done the installation instructions on https://github.com/Alamofire/Alamofire but when it comes to step 6 , how and where do I get the alamofire.framework file? I am new to this, so sorry if it is a stupid question. 回答1: You have to open yourprojectname.xcworkspace You might get this error if you are opening your

Realm data Insertion took over 7mins for big size json

ⅰ亾dé卋堺 提交于 2019-12-06 20:38:30
I use Alamofire to download big json data which was about around 7MB and use RealmSwift to store data at realmobject and SwiftyJSON to parse.My realm object insertion after it finished download the json seems really slow at insertion.Was something wrong with my bad code?Please guide me. First of all I will show simplest Json : { { "Start" : "40000", "End" : "1000000", "Name" : "Smith", "Address" : "New York" },{...},more than 7000 records... } Here is my AlamofireAPI Protocol import Foundation import Alamofire import SwiftyJSON protocol RequestDataAPIProtocol{ func didSuccessDownloadingData

How to parse JSON using Alamofire 4.7 in Swift 4

故事扮演 提交于 2019-12-06 18:04:51
问题 I know this question was asked before, but answers were in Swift 3 and using older versions of Alamofire. Problem: Can't figure out how to retrieve data from JSON response, mainly api_key . Here is code for my response: Alamofire.request(serverLink!, headers: headers).responseJSON{ response in if response.value != nil { //Some code to get api_key print(response) } else { print("error") } When I print(response) I get the following: SUCCESS: { user = { "api_key" =