草庐IT

Alamofire

全部标签

ios - Swift:使用 Alamofire 和 SwiftyJSON 处理 JSON

这肯定会被问到好几次,但我还没有找到正确的答案,虽然我一直在努力寻找。我使用Alamofire和SwiftyJSON,我的JSON数据如下所示:{"528":{"name":"Name1","id":"528","product_id":null,"visible":"0","level":"2"},"29":{"name":"Name2","id":"29","product_id":null,"visible":"1","level":"1"},"173":{"name":"Name3","id":"173","product_id":null,"visible":"0","lev

ios - 多次调用一个 Alamofire 请求,获取每次调用的引用

我使用Alamofire以多部分形式数据上传图像。我成功地实现了我的目标。每次上传图像时,我都会调用“uploadDocWebService”函数。因此函数被调用的次数等于图像的数量。我无法确定每次通话的结果。我的图片上传成功。如果服务器出现故障,或互联网连接失败,上传失败,我无法确定我应该从View中删除哪个失败的图像。我将indexPath作为每个图像上传的参数传递。但是在我收到第一张图片上传的结果之前,indexPath会更新到最新的图片上传。任何人都可以建议我针对这种情况采取更好的方法。这是我用于上传图片的代码:funcuploadDocWebservice(fileUrl:N

ios - 我需要将我的 Alamofire 调用包装在 dispatch_async 中吗?

funcauthenticate(completion:(success:Bool)->Void){letqos=Int(QOS_CLASS_USER_INITIATED.value)dispatch_async(dispatch_get_global_queue(qos,0)){()->VoidinAlamofire.request(.POST,CONSTANTS.Domain+"/accounts",parameters:["":""]).responseJSON{(req,res,json,error)indispatch_async(dispatch_get_main_queu

ios - 迦太基更新时出现 Alamofire 错误

我的购物车文件:github"ReactiveCocoa/ReactiveCocoa""v4.0.0-alpha.4"github"ikesyo/Himotoki"~>1.3.0github"Alamofire/Alamofire"~>3.1.2github"Swinject/Swinject"==0.5.0github"Quick/Quick"==0.8.0github"Quick/Nimble"==3.0.0错误:***FetchingReactiveCocoa***FetchingHimotoki***FetchingAlamofire***FetchingSwinject***

使用 Alamofire 从 iOS 上传 PHP

我正在尝试将3张图像从iOS上传到服务器到我的PHP服务。由于某种原因,文件夹在发布后仍然是空的,但其余数据会通过并持久保存到mysql中。我的iOS代码:Alamofire.upload(.POST,urlString,multipartFormData:{multipartFormDatainif(firstPhoto!=nil){ifletfirstImageData=UIImageJPEGRepresentation(firstImage!,0.6){print("uploadingimage");multipartFormData.appendBodyPart(data:fi

swift - 如何取消 Alamofire.upload

我正在通过Alamofire.upload将图像作为多部分数据上传到服务器。与Alamofire.request不同,它不返回Request对象,我通常用它来取消请求。但是能取消上传这种耗时的请求是很合理的。Alamofire对此有哪些选择? 最佳答案 使用UploadingMultiPartFormData来自Alamofire自述文件的示例:Alamofire.upload(.POST,"https://httpbin.org/post",multipartFormData:{multipartFormDatainmultipa

json - Alamofire上传参数如何添加Int值

我想将Int值添加到multipartFormData:Alamofire.upload(.POST,url,headers:headers,multipartFormData:{multipartFormDatain//addsomejpgimage//addothervaues:for(key,value)inparameters{ifvalueisString{multipartFormData.appendBodyPart(data:value.dataUsingEncoding(NSUTF8StringEncoding)!,name:key)}elseifvalueisInt

ios - Xcode 找不到 Alamofire,错误 : No such module 'Alamofire'

我正在尝试按照github(https://github.com/Alamofire/Alamofire#cocoapods)指令将Alamofire包含在我的Swift项目中。我创建了一个新项目,导航到项目目录并运行此命令sudogeminstallcocoapods。然后我遇到了以下错误:ERROR:Whileexecutinggem...(Errno::EPERM)Operationnotpermitted-/usr/bin/pod搜索后,我设法通过运行此命令安装cocoapodssudogeminstall-n/usr/local/bincocoapods现在我通过podini

swift - 用 Alamofire 记住 cookie

我试图让我的Alamofire管理器实例自动记住并设置cookie,这是我不成功的尝试:letcfg=NSURLSessionConfiguration.defaultSessionConfiguration()letcooks=NSHTTPCookieStorage.sharedHTTPCookieStorage()//makesnodifferencewhetherit'ssetorleftatdefaultcfg.HTTPCookieStorage=cookscfg.HTTPCookieAcceptPolicy=NSHTTPCookieAcceptPolicy.Alwayslet

swift - Alamofire 响应序列化失败(Alamofire.AFError.ResponseSerializationFailureReason.inputDataNilOrZeroLength)

我有一些工作代码可以从远程Web服务器上的MySQL数据库获取结果。它不再工作,我不断收到消息responseSerializationFailed(Alamofire.AFError.ResponseSerializationFailureReason.inputDataNilOrZeroLength)。这是一些代码...Alamofire.request(ADS_URL,method:.get).validate().responseJSON{responseinprint("Request:\(String(describing:response.request))")//ori