草庐IT

Alamofire-SwiftyJSON

全部标签

json - 使用字典将 alamofire 中的 JSON 数据解析为数组

我正在尝试按如下方式解析来自alamorefire的JSON数据。importUIKitimportAlamofireimportSwiftyJSONclassViewController:UIViewController{overridefuncviewDidLoad(){super.viewDidLoad()Alamofire.request(.GET,"https://api.mynexttrainschedule.net/").responseJSON{responseinguardletobject=response.result.valueelse{print("Oh,no

ios - 如何在没有任何第三方库的情况下在 Swift 3.0 中使用 Alamofire 解析 JSON

这里我想通过url解析JSON。这是url上可用的实际JSON数据。所以我需要解析它并使用Alamofire在我的应用程序中读取。但是我做不到。我的网址中的JSON数据。{"main":[{"date":"2017-01-11","USDARS":"15.8302","USDCLP":"670.400024","USDSDG":"6.407695"},{"date":"2017-01-12","USDARS":"15.804999","USDCLP":"661.599976","USDSDG":"6.407697"},{"date":"2017-01-13","USDARS":"15.

ios - 如何将 json 数据从 alamofire 转换为 swift 对象

hithereimmakingaphotoviewerappinswiftusingswift1.1inxcode6.2iamahavingtroubletryingtoconvertjsonresponsefromalamofiretoswiftobjects.ihaveusedswiftyjsonlibrarybutitseemsthereisacompatibilityissues.hereismymodelclassimportFoundationstructPhoto{varname:Stringvarfilename:Stringvarnotes:String}hereis

ios - Alamofire JSON 请求不从服务器中提取数据

我正在使用Alamofire从服务器(http://midlandgates.co.uk/JSON/reliveCacheData.json)中提取一个JSON文件。为此,我有一个AlamofireRequest函数,它应该拉取数据并将其写入一个名为JSONDataClass的类。Alamofire请求Alamofire.request(.GET,"http://midlandgates.co.uk/JSON/reliveCacheData.json").response{request,response,data,errorinifletdata=data{letjson=JSON(

swift - 我应该如何处理 shouldPerformSegueWithIdentifier 中的 Alamofire 响应?

我正在尝试学习Swift,我想做的是创建简单的登录页面。每当用户单击登录按钮时,我都会在shouldPerformSegueWithIdentifier中向我的Web服务发出请求,以检查用户名和密码是否正确。我不想使用IBAction(如touchupinside等)。解析来自Web服务的响应后,我检查是否有任何错误来自Web服务响应(例如用户名无效)。如果有任何错误,我想通过返回false来防止segue。但我不能在Alamofire内部返回false。那我应该怎么处理呢?这是我的代码:overridefuncshouldPerformSegueWithIdentifier(iden

swift - 使用 Alamofire 4 swift 3 上传图片

我想用alamofire将照片上传到服务器我现在正在使用此代码,但我正在超时letimageData=UIImageJPEGRepresentation(croppedImage,1)leturlRequest=self.urlRequestWithComponents(url,imageData:imageData!)self.alamofire.upload(urlRequest.1,to:urlRequest.0as!URLConvertible).responseJSON{responseinguardresponse.result.isSuccesselse{self.sho

swift - 如何对来自 Alamofire 的 JSON 进行排序并返回最终的 JSON 对象 (swiftyJSON)

我无法简洁地从API中提取数据,将用户当前位置添加到对象中,然后根据计算出的距离对数据进行排序。stackoverflow问题并不能完全回答我面临的问题。看这里:HowtosortpostsreadfromJSONserverfileinSwift.我目前正在从Alamofire加载api数据并使用UITableViewController呈现该数据。overridefuncviewDidLoad(){super.viewDidLoad()titleLabel.title=q.capitalizedStringAlamofire.request(.GET,"http://www.the

ios - 如何使用带有 xml 正文的 alamofire 发送请求

我在我的项目中安装了Alamofire,现在这就是我所做的。我安装了postman我把我的url和insidebody一个xml对象,我得到了我的结果。这是一张我用postman做的照片我现在如何使用Alamofire或SWXMLHash发送它,就像我用postman发送它一样提前致谢!编辑我从另一个问题试过了:Alamofire.request(.POST,"https://something.com",parameters:Dictionary(),encoding:.Custom({(convertible,params)inletmutableRequest=convertib

ios - Alamofire swift 库版本 4.4 未安装在 swift 3.0.2 项目中

我正在尝试使用pod在我的swift项目中安装Alamofire4.4我正在按照给定链接(https://github.com/Alamofire/Alamofire)中的步骤操作但我面临这个问题:-[!]Unabletosatisfythefollowingrequirements:-`Alamofire(~>4.4)`requiredby`Podfile`Noneofyourspecsourcescontainaspecsatisfyingthedependency:`Alamofire(~>4.4)`.Youhaveeither:*out-of-datesourcereposwh

ios - Postman Body 对 Swift Alamofire 的原始请求

我正在尝试重新创建此Postman设置以在Alamofire中发帖。这是我第一次看到需要参数和原始Json主体的API。我已完成收集和格式化我的数据(在Json中使用SwiftyJSON或字典[String:Any]/Parameters)以满足上述要求。虽然我确实看到了与此类似的问题:PostmanrequesttoAlamofirerequest但它没有有效的答案。假设我对从各种API发布/获取/等数据非常有经验,但我只是不知道如何像上图那样传递原始数据。请在代码中查看我的评论。以下是我针对此请求对函数所做的操作:/**ApplytojobwithShift.*Thisservic