草庐IT

Alamofire-SwiftyJSON

全部标签

ios - 在 Swift 中使用 Alamofire 解析 JSON 响应

使用Alamofire框架时,我的响应似乎没有得到正确的解析。我得到的JSON响应有一些键似乎不是字符串,我不知道如何引用它们/获取它们的值。这是我调用的代码部分:varurl="http://api.sandbox.amadeus.com/v1.2/flights/low-fare-search"varparams=["origin":"IST","destination":"BOS","departure_date":"2014-10-15","number_of_results":1,"apikey":KEY]Alamofire.request(.GET,url,paramete

swift - 快速的 Alamofire 和内存警告

我是Alamofire框架的新手。我尝试下载数据文件。代码是:Alamofire.download(.GET,urlStr,{(temporaryURL,response)inifletdirectoryURL=NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory,inDomains:.UserDomainMask)[0]as?NSURL{letpathComponent=response.suggestedFilenamereturndirectoryURL.URLByAppendingPathCompo

php - Swift/PHP 如何使用 Alamofire 在 UITableView 中显示 mysql 数据(json)

我想创建一个只返回一个单元格的TableView。在这个单元格中包含三个标签:id、username和category。这将导致让用户看到他的基本详细信息。当我运行应用程序时,我的UITableView仍然没有显示任何结果(空白)。任何人都可以查看我的代码以使其正常工作吗?我看不出哪里错了,因为我在Xcode中没有收到任何错误表格ViewControllerimportUIKitimportAlamofireclassMyProfile:UITableViewController{varusers=[MyProfileBasicData]()overridefuncviewDidLoa

arrays - SwiftyJSON 将新数据附加到现有的 JSON 数组

我正在研究一种将新的JSON数据添加到现有JSON数组的方法:varresources:JSON=["resources":[]]overridefuncviewDidLoad(){super.viewDidLoad()getApiResourceA(){responseObject,errorinvarresourceA:JSON=["resourceA":[]]letresourceAResponseObject=JSON(responseObject!)resourceA["resourceA"]=resourceAResponseObjectself.resources["re

json - SwiftyJSON 字符串值为空

我在Swift中解析JSON时遇到问题。我使用SwiftyJSON框架。我的数据来自网络:letdataString:NSString=NSString(data:data,encoding:NSUTF8StringEncoding)!;打印这个:println("Receiveddata:\(dataString)")给我的JSON:Receiveddata:{"result":"success"}但是当我尝试读取结果值时:letjson=JSON(dataString);println(json["result"].stringValue);//然后输出为空。我尝试了不同的方法,例

ios - Alamofire,错误消息使用未声明的类型 'GenericResponseSerializer'

我遵循raywanderlich的alamofire/swiftturorial,我使用swift2.0和alamofire3.0beta3。现在我已经处理了一些小问题,但我仍然坚持这个问题message:Useofundeclaredtype'GenericResponseSerializer'Generictype'Result'specializedwithtoofewtypeparameters(got1,butexpected2)这是我的代码的一部分extensionAlamofire.Request{/**Responseserializerforimagesfrom:ht

swift - iOS http POST 使用 Alamofire

我需要一些帮助来使用Alamofire通过来自Twilio的API使用用户名/密码对网页进行POST。我之前使用过GitHub的SwiftRequest,但它不支持Swift2.0。我使用的代码(使用SwiftRequest)是:vardata=["To":mobileInput.textasString!,"From":twilioSMSFrom,"Body":String(code)asString]varswiftRequest=SwiftRequest()swiftRequest.post("https://api.twilio.com/2010-04-01/Accounts/

swift - 使用 SwiftyJSON 和 Alamofire 遍历 JSON

我已经查看了其他问题,但似乎找不到可以回答我问题的问题。我有这个Json文件:["posts",{"2015":["posttitleone"],"2016":["posttitleone","posttitletwo"]}]我的Swift文件中有这段代码:Alamofire.request(.GET,url).validate().responseJSON{responseinswitchresponse.result{case.Success:ifletvalue=response.result.value{letjson=JSON(value)for(key,subJson)in

json - 使用 Swift + Alamofire + Swifty-Json 将动态数据传递给 UIScrollView

我有一个ViewController,它有一个UIScrollView。UIScrollView加载三个ViewControllersvc0,vc1,vc2:问题在ViewController上,我使用Alamofire和SwiftyJson加载数据:Alamofire.request(.GET,url,parameters:["foo":"bar"]).responseJSON{responseinswitchresponse.result{case.Success:ifletvalue=response.result.value{letjson=JSON(value)dispatc

json - 如何使用 Alamofire 和 SwiftyJSON 访问嵌套的 JSON 值?

我正在尝试使用swiftyJSON和Alamofire访问嵌套的JSON结果。我的打印值(value)为零,我相信我没有正确地这样做。我的参数应该是什么?我正在尝试获取位于http://quotes.rest/qod.json的报值(value)funcgetAPI(){Alamofire.request(.GET,"http://quotes.rest/qod.json",parameters:["contents":"quotes"]).responseJSON{responseinifletJSON=response.result.value{print(JSON["quote"