草庐IT

Alamofire4

全部标签

swift - 使用 Alamofire + SwiftyJSON 获取 JSON 数组

我真的是Swift的新手,抱歉,如果这是一个愚蠢的问题......似乎有很多关于这个的问题,但没有一个使用最新版本的AlamofireAlamofire.request(.GET,url).responseJSON{responseinletjson=JSON(response.data!)debugPrint(json)self.delegate?.didReceiveAPIResults(json)}以及委托(delegate)的didReceiveAPIResults方法funcdidReceiveAPIResults(results:JSON){dispatch_async(d

ios - Alamofire 下载数据后的返回值

我有一个使用Alamofire下载数据的功能,然后我想返回该数据。现在我知道Alamofire是异步运行的,为了返回数据我应该使用completionHandler,但是我不知道如何使用它。由于我不是第一个遇到此类问题的人,因此我找到了一些类似问题的解决方案,但我不确定将它们应用到我的案例中。这是我的代码:funcdownloadImageFromServer(imageUrl:String)->(String,String){varmyData1=String()varmyData2=String()Alamofire.request(.GET,imageUrl).responseI

ios - 使用 Alamofire 的 cURL 请求

我正在尝试使用Alamofire来完成这个cURL请求curl-XPOST-H"Content-Type:application/json"\--user":"\-d'{"grant_type":"client_credentials","scope":"public"}'\'https://api.lyft.com/oauth/token'我目前有:letplainString="clientID:clientSecret"asNSStringletplainData=plainString.dataUsingEncoding(NSUTF8StringEncoding)letbase

ios - Alamofire 构建失败 : issues in Manager. swift、Request.swift 和 ResponseSerialization.swift

我在我的项目中添加了Alamofire框架,之后如果我尝试构建项目,它会在这些Alamofire文件中引发错误:Manager.swift、Request.swift和ResponseSerialization.swift错误截图如下: 最佳答案 更新Xcode。您安装的Alamofire版本针对的是最新的Swift版本,但是您的Xcode版本比那个版本旧,因此它无法识别语法。 关于ios-Alamofire构建失败:issuesinManager.swift、Request.swift

ios - 如何在 Alamofire 中将响应值保存到 NSDictionary?

我正在使用Alamofirev3.4.1,我正在通过这样的GET方法获取JSON结果,@IBActionfuncverifyAction(sender:AnyObject){lettempEmail:String="\(emailTxtField.text!)"lettempApi:String=appDelegate.apiKeyasStringvarstatus:StringAlamofire.request(.GET,"http://www.somejsonurl.com/checkEmailExits",parameters:["APIKey":"\(tempApi)","Em

ios - 使用 Alamofire.upload 时出现段错误 : 11,

我将Swift3的Alamofire更新为4.0。(在我使用AFNetworking之前)。我的代码:funcuploadImage(_image:Data,withURLRequresturlRequest:URLRequestConvertible,responseCallback:((NetworkResponse)->())?=nil){Alamofire.upload(multipartFormData:{multipartFormDatain_=multipartFormData.appendBodyPart(data:image,name:"imagefile",file

ios - 使用 Alamofire 和 Swift 3 反序列化复杂的 JSON

如何反序列化此JSON并在tableView中显示标题JSON:https://www.healthcare.gov/api/articles.json到目前为止我尝试了什么:structNews{lettitle:Stringinit(dictionary:[String:String]){self.title=dictionary["mainTitle"]??""}}varnewsData=[News]()funcdownloadData(){Alamofire.request("https://www.healthcare.gov/api/articles.json").resp

ios - 库未加载 - Alamofire

几个小时以来,我一直被一个错误所困扰。我正在使用Alamofire构建框架并在iOS项目中对其进行测试。每当我运行该项目时,我都会收到此错误:dyld:Librarynotloaded:@rpath/Alamofire.framework/AlamofireReferencedfrom:/Users/theodorestrauss/Library/Developer/Xcode/DerivedData/TGClient-ecnnvvvxipoufihfghkpxlfccyoc/Build/Products/Debug-iphonesimulator/TGClient.framework

ios - 使用 Alamofire 通过 Swift 从 Google 获取短 URL

我正在尝试在我的应用程序中添加短url作为用户的工具,这是来自thisanswer的不幸的是它没有用!:importAFNetworkingletgoogleShortURLKey="MYKEY"funcgetShortURLFromGoogle(longURL:String){letmanager=AFHTTPSessionManager()manager.requestSerializer=AFJSONRequestSerializer()asAFJSONRequestSerializerletparams=["longUrl":longURL]manager.POST("http

ios - Swift 如何使用 Alamofire 和 SSZipArchive 从 URL 解压缩文件

funcdownLoad(fileName:String){leturlString:String="\(myurl)\(fileName)"varlocalPath:NSURL?letdestination=DownloadRequest.suggestedDownloadDestination(for:.documentDirectory)Alamofire.download(urlString,method:.get,encoding:JSONEncoding.default,to:destination).downloadProgress(queue:DispatchQueue