alamofire

Load data from json using UIPickerView

巧了我就是萌 提交于 2019-11-28 02:04:13
问题 My Current View Controller is like this import UIKit import Alamofire class ViewController: UIViewController , UIPickerViewDelegate, UIPickerViewDataSource{ @IBOutlet var venuePicker : UIPickerView? var result = [String:String]() var resultArray = [String]() override func viewDidLoad() { self.venuePicker?.delegate = self Alamofire.request(.POST, "http://example.com/xxx/xx/xx").responseJSON() { (request, response, jsonData, error) in var venues = JSON(jsonData!) let d = venues.dictionaryValue

How to decode a JSON property with different types? [duplicate]

亡梦爱人 提交于 2019-11-28 01:57:04
问题 This question already has an answer here : What Is Preventing My Conversion From String to Int When Decoding Using Swift 4’s Codable? (1 answer) Closed last year . I have a JSON { "tvShow": { "id": 5348, "name": "Supernatural", "permalink": "supernatural", "url": "http://www.episodate.com/tv-show/supernatural", "description": "Supernatural is an American fantasy horror television series created by Eric Kripke. It was first broadcast on September 13, 2005, on The WB and subsequently became

Handle JSON Response with Alamofire in Swift

断了今生、忘了曾经 提交于 2019-11-28 01:40:56
sorry for my bad english :) I have a problem to parse JSON response over Alamofire in Swift for an iOS app. I wrote a function to return a string of JSON response. The request and response handling I do with Alamofire and the JSON handling I do with SwiftyJSON . At the begin I declare a var called jsonString with the value test . Then I do a request to an REST Service and get a JSON response by clicking a button. This response I want to return with the function ping(url:String) . At the end I print the returned response as a test. But on the first click on the button the return value from ping

Alamofire: Send JSON with Array of Dictionaries

江枫思渺然 提交于 2019-11-28 01:34:15
问题 I have a data structure that looks like this in JSON: [{ "value": "1", "optionId": "be69fa23-6eca-4e1b-8c78-c01daaa43c88" }, { "value": "0", "optionId": "f75da6a9-a34c-4ff6-8070-0d27792073df" }] Basically it is an array of dictionaries. I would prefer to use the default Alamofire methods and would not like to build the request manually. Is there a way to give Alamofire my parameters and Alamofire does the rest? If I create everything by hand I get an error from the server that the send data

Returning a value from a function with Alamofire and SwiftyJson

℡╲_俬逩灬. 提交于 2019-11-28 01:32:48
I have an app that returns a menu of information (basically menus, menu_headers, and items). I'd like to have something like this: EKMenu.getMenu(menu_id: Int) that would return a menu but I think I would need a completion handler in here. I currently have: class func getMenu(menu_id: Int){ //class func getMenu(menu_id: Int, completionHandler:(NSArray -> Void)){ let url="https://www.example.com/arc/v1/api/menus/\(menu_id)/mobile" Alamofire.request(.GET, url).responseJSON() { (_, _, data, _) in println("within menu request") var json=JSON(data!) var menu=EKMenu() menu.name=json["menu"]["name"]

Waiting for Alamofire in Unit Tests

你。 提交于 2019-11-28 01:02:06
问题 I'm trying to write a method where a data object (Realm) refreshes it's properties using Alamofire. But I can't figure out how to unit test it. import Alamofire import RealmSwift import SwiftyJSON class Thingy: Object { // some properties dynamic var property // refresh instance func refreshThingy() { Alamofire.request(.GET, URL) .responseJSON { response in self.property = response["JSON"].string } } } In my unit tests, I want to test that the Thingy can refresh from server properly. import

Swift 3 - Alamofilre 4.0 multipart image upload with progress

强颜欢笑 提交于 2019-11-27 23:14:59
I've done with image upload and its successfully uploaded on server using below method. Now I want to upload image with its progress so can any one tell me how to do? I found on everywhere but didn't got the correct solution. Code for image upload without it's progress : @IBAction func uploadClick(_ sender: AnyObject) { // define parameters let parameters = [ "file_name": "swift_file.jpeg" ] Alamofire.upload(multipartFormData: { (multipartFormData) in multipartFormData.append(UIImageJPEGRepresentation(self.photoImageView.image!, 0.5)!, withName: "photo_path", fileName: "swift_file.jpeg",

Error Domain=NSPOSIXErrorDomain Code=100 “Protocol error”

懵懂的女人 提交于 2019-11-27 22:15:55
I am trying to call a service using Alamofire using a .get method. The request has nothing special no parameters just an Authorization header. I am going a bit mad here because to request works fine when I run it on postman with the same URL and Authorization token, but when I run my app code with Alamofire it returns this error: Error Domain=NSPOSIXErrorDomain Code=100 "Protocol error" UserInfo={NSErrorPeerAddressKey={length = 16, capacity = 16, bytes = 0x100201bbd83ad0b10000000000000000}, _kCFStreamErrorCodeKey=100, _kCFStreamErrorDomainKey=1} I am using: Alamofire.request("https:/

iOS 9.3 : An SSL error has occurred and a secure connection to the server cannot be made

泪湿孤枕 提交于 2019-11-27 19:47:18
I am getting following error with self signed certificate Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made. while testing web-services for one of my demo app with iOS 9.3 XCode 7.3 Swift 2.2 Alamofire 3.3.0 and Local server : https://filename.hostname.net Note: before assuming its Duplicate, I would request please read it all the way,even same i have reported to apple dev forums Using Alamofire Library func testAlamofireGETRequest() -> Void { Alamofire.request(.GET, "https://filename.hostname.net/HelloWeb/service/greeting

Alamofire: responseSerializationFailed(Alamofire.AFError.ResponseSerializationFailureReason.inputDataNilOrZeroLength)

谁说胖子不能爱 提交于 2019-11-27 19:41:49
问题 I am trying to upload data through alamofire including images. But it returns responseSerializationFailed(Alamofire.AFError.ResponseSerializationFailureReason.inputDataNilOrZeroLength) -- and my code is , Alamofire.upload(multipartFormData: { (multipartFormData) in multipartFormData.append((userid?.data(using: String.Encoding.utf8))!, withName: "user_id") multipartFormData.append((self.addUserBtnTag?.description.data(using: String.Encoding.utf8))!, withName: "slot") }, to: urlString, method: