草庐IT

AlamoFire

全部标签

swift - AlamoFire GET api 请求未按预期工作

我正在努力学习如何使用AlamoFire,但遇到了麻烦。目前我的方法如下:funcsiteInfo()->String?{varinfo:NSDictionary!varstr:String!Alamofire.request(.GET,MY_API_END_POINT).responseJSON{(request,response,JSON,error)ininfo=JSONasNSDictionarystr=info["access_key"]asString//returnstr}returnstr}这会返回nil,这是一个问题。从我读到的here,这是因为请求可能需要一段时间,

ios - 命令/bin/sh 失败,退出代码为 1 和嵌入式 pods 框架

无法确定实际问题,在更新cocopod期间收到消息“由于主要版本更新而重新创建CocoaPods。”(那只来过一次)并且pod更新成功。构建后我收到错误。命令/bin/sh失败,退出代码为1。下面是我得到的一些细节代码签名/Users/Gaurav/Library/Developer/Xcode/DerivedData/Appname-******/Build/Products/Debug-iphoneos/Appname.app/Frameworks/Alamofire.frameworkwithIdentityiPhone开发者:账户名(AccountId)/usr/bin/cod

ios - 命令/bin/sh 失败,退出代码为 1 和嵌入式 pods 框架

无法确定实际问题,在更新cocopod期间收到消息“由于主要版本更新而重新创建CocoaPods。”(那只来过一次)并且pod更新成功。构建后我收到错误。命令/bin/sh失败,退出代码为1。下面是我得到的一些细节代码签名/Users/Gaurav/Library/Developer/Xcode/DerivedData/Appname-******/Build/Products/Debug-iphoneos/Appname.app/Frameworks/Alamofire.frameworkwithIdentityiPhone开发者:账户名(AccountId)/usr/bin/cod

ios - 如何在 Alamofire 中暂停/恢复/取消我的下载请求

我正在使用Alamofire下载文件,但我不知道如何暂停/恢复/取消特定请求。@IBActionfuncdownloadBtnTapped(){Alamofire.download(.GET,"http://httpbin.org/stream/100",destination:destination).progress{(bytesRead,totalBytesRead,totalBytesExpectedToRead)inprintln(totalBytesRead)}.response{(request,response,_,error)inprintln(response)}}

ios - 如何在 Alamofire 中暂停/恢复/取消我的下载请求

我正在使用Alamofire下载文件,但我不知道如何暂停/恢复/取消特定请求。@IBActionfuncdownloadBtnTapped(){Alamofire.download(.GET,"http://httpbin.org/stream/100",destination:destination).progress{(bytesRead,totalBytesRead,totalBytesExpectedToRead)inprintln(totalBytesRead)}.response{(request,response,_,error)inprintln(response)}}

ios - 带有自签名证书/ServerTrustPolicy 的 Alamofire

我想使用Alamofire通过带有自签名证书的https连接与我的服务器通信。我的环境在本地主机上运行。我已尝试连接,但响应始终如下所示:Success:falseResponseString:nil我用下面的代码完成了它:importFoundationimportUIKitimportAlamofireclassMessageView:UITableViewController{letdefaultManager:Alamofire.Manager={letserverTrustPolicies:[String:ServerTrustPolicy]=["localhost":.Di

ios - 带有自签名证书/ServerTrustPolicy 的 Alamofire

我想使用Alamofire通过带有自签名证书的https连接与我的服务器通信。我的环境在本地主机上运行。我已尝试连接,但响应始终如下所示:Success:falseResponseString:nil我用下面的代码完成了它:importFoundationimportUIKitimportAlamofireclassMessageView:UITableViewController{letdefaultManager:Alamofire.Manager={letserverTrustPolicies:[String:ServerTrustPolicy]=["localhost":.Di

ios - Alamofire:遵循 HTTP 重定向(或不遵循)

我正在尝试将Alamofire配置为在每个请求的基础上遵循重定向(或不遵循)。Alamofire有一个私有(private)的内部类SessionDelegate作为当前URLsession的NSURLSessionTaskDelegate。SessionDelegate确实实现了相关的委托(delegate)方法,URLSession(session:,task:,willPerformHTTPRedirectionresponse:,request:,completionHandler:)这正是我想要的。更好的是,委托(delegate)的实现引用了一个名为taskWillPerf

ios - Alamofire:遵循 HTTP 重定向(或不遵循)

我正在尝试将Alamofire配置为在每个请求的基础上遵循重定向(或不遵循)。Alamofire有一个私有(private)的内部类SessionDelegate作为当前URLsession的NSURLSessionTaskDelegate。SessionDelegate确实实现了相关的委托(delegate)方法,URLSession(session:,task:,willPerformHTTPRedirectionresponse:,request:,completionHandler:)这正是我想要的。更好的是,委托(delegate)的实现引用了一个名为taskWillPerf

swift - 如何添加 Alamofire URL 参数

我有一个使用Postman传递URL参数的工作场景。现在,当我尝试在Swift中通过Alamofire执行此操作时,它不起作用。您将如何在Alamofire中创建此url?http://localhost:8080/?test=123_url="http://localhost:8080/"letparameters:Parameters=["test":"123"]Alamofire.request(_url,method:.post,parameters:parameters,encoding:URLEncoding.default,headers:headers