alamofire

NSInvalidArgumentException Invalid type in JSON write DemographicsPojo

不想你离开。 提交于 2019-12-11 05:52:06
问题 I am getting a NSInvalidArgumentException when I try to run the following JSONSerialization using Alamofire on swift 3 code. try! JSONSerialization.data(withJSONObject: postData, options: JSONSerialization.WritingOptions.prettyPrinted) On debug, postData is returning the value below. key __NSCFString * "demographicsPojo" 0x000060800005e8a0 value _TtC7MyApp16DemographicsPojo * 0x6080001c5cd0 0x00006080001c5cd0 [0] _TtC7MyApp16DemographicsPojo createdTimeMilliSecs Int64? 1487253369999

Class does not conform to protocol RequestRetrier

最后都变了- 提交于 2019-12-11 05:42:30
问题 I have been migrating my project to swift3 and have been battling to get Alamofire RequestRetrier protocol to work. I have followed Alamofire 4.0 migrating guide: https://github.com/Alamofire/Alamofire/blob/master/Documentation/Alamofire%204.0%20Migration%20Guide.md#request-retrier This is the class I'm trying to build: import Foundation import Alamofire class RequestAccessTokenAdapter: RequestAdapter, RequestRetrier { private let accessToken: String init(accessToken: String) { self

possible to cast this Alamofire result to an array of dictionaries

拈花ヽ惹草 提交于 2019-12-11 05:38:01
问题 I am not an iOS dev and have to make a few changes to a Swift / AlamoFire project (not mine) and am a bit lost. I have the following JSON: {"metro_locations": [ { "name":"Ruby Red" }, { "name":"Blue Ocean" } ] } class (I know that there are issues here): class Location{ var name="" init(obj:tmp){ self.name=tmp["name"] } } and need to make an AlamoFire call Alamofire.request(.GET, "https://www.domain.com/arc/v1/api/metro_areas/1", parameters: nil) .responseJSON { response in if let

Alamofire, Extra argument 'method' in call [duplicate]

↘锁芯ラ 提交于 2019-12-11 05:14:12
问题 This question already has answers here : Swift 3.0, Alamofire 4.0 Extra argument 'method' in call (5 answers) Closed 8 months ago . I have google some answers with no luck, I got this error "Extra argument 'method' in call" and is pointing at the ".get", but if i remove the "headers : headers as? [String: Any]" it works. Please help let urlParams:[String : Any] = [ "target": target, "q": textToTranslate, "key": GOOGLE_CLOUD_API_KEY, "source": source] let headers:[String : Any] = ["Content

ObjectMapper Array or Object based on Data

為{幸葍}努か 提交于 2019-12-11 05:09:19
问题 I'm trying to achieve something generic to parse my JSON response so far i'm able to get them this close class ParentJson<T: Mappable> : Mappable { var StatusCode: Int? var Message: String? var dataArray: [T]? var dataObject: T? required init?(map: Map) { } func mapping(map: Map) { StatusCode <- map["StatusCode"] Message <- map["Message"] dataArray <- map["Data"] dataObject <- map["Data"] } } class DataJson: Mappable { var OffsiteReportID: Int? var InspectionActivityID: Int? var

Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0

前提是你 提交于 2019-12-11 04:47:38
问题 Hi I am new at swift and I got problem, I made a request to server with post method and I get response with good Json, after that I am makeing another request with get method but I get this error. Error: responseSerializationFailed(Alamofire.AFError.ResponseSerializationFailureReason.jsonSerializationFailed(Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.}) Parameters for request: static func

Need Help Parsing JSON with Swift using Alamofire

二次信任 提交于 2019-12-11 04:31:34
问题 I'm trying to retrieve an article from Google news and parse it using Swift. I'm using Alamofire. I know the basics of what to when parsing, but the output seems kind of complex and I don't know how to access the "title" value. Any help would be appreciated. Thanks! Here is the JSON Output: responseData = { cursor = { currentPageIndex = 0; estimatedResultCount = 445755633; moreResultsUrl = "http://news.google.com/nwshp?oe=utf8&ie=utf8&source=uds&q=sports&hl=en&start=0"; pages = ( { label = 1;

Unable to upload images in ios 11.0.3

二次信任 提交于 2019-12-11 04:28:15
问题 I am facing a really weird problem. I am trying to pick an image and upload the same after cropping it, to the server. I am unable to do it on my iphone 5s running on ios 11.0.3. But the same is working fine on iphone 5 which is running ios 10.3.3. I am using the following code to pick the image from gallery: func showImgPicker() { self.imagePicker.allowsEditing = false self.imagePicker.sourceType = .photoLibrary self.present(self.imagePicker, animated: true, completion: nil) } @IBAction func

json post nested objects in swift using alamofire

喜欢而已 提交于 2019-12-11 04:22:27
问题 i want to post nested json objects in API using Alamofire my objects structere is like this ["example" : { "fname":"john", "lnamed":"Doe" },{ "fname":"john", "lname":"Doe" }, . . . ] my problem is when i'm making array it becomes like ["example": [ ["fname":"john","lname":"Doe"],["fname":"john","lname":"Doe"] ] ] so their is one square bracket extra because of the array. below is my codes var exampleObj = [String:AnyObject]() var examplesArray = [exampleObj] for example in examples {

Wait until alamofire is done getting request and making object [duplicate]

╄→гoц情女王★ 提交于 2019-12-11 04:07:53
问题 This question already has an answer here : Swift Function to parse JSON and return a array of dictionaries (1 answer) Closed 2 years ago . I am having a problem with waiting until one object is made, then I wish to update my UI. If i run the function, it will instantly get the out of index error because its trying to get some text from the first object when it dosent exist yet... Anyone who could help me? func getMovieData(activeGenreLink: String){ //self.posterLoading.startAnimating()