草庐IT

AlamoFire

全部标签

ios - Alamofire:[结果]:失败:错误域=NSURLErrorDomain 代码=-999 "cancelled"

我要连接的服务使用的是自签名证书。出于开发目的,我不想验证该链。将swift3与Alamofire4结合使用。相应地修复了ATS:NSAppTransportSecurityNSExceptionDomainsurl.comNSExceptionAllowsInsecureHTTPLoadsNSExceptionRequiresForwardSecrecyNSIncludesSubdomains连接和禁用评估的代码。letserverTrustPolicies:[String:ServerTrustPolicy]=["example.domain.com":.pinCertificat

ios - 在 Alamofire (Swift) 中保存 cookie

我想存储我的cookie,这样当我重新打开应用程序时,我可以恢复存储在前一个实例中的那些。要初始化alamofire,我使用:letmanager=Alamofire.Manager.sharedInstance我加载cookie的代码是:letcookies=NSHTTPCookie.cookiesWithResponseHeaderFields(headerFields,forURL:URL)Alamofire.Manager.sharedInstance.session.configuration.HTTPCookieStorage?.setCookies(cookies,for

ios - 在 Alamofire (Swift) 中保存 cookie

我想存储我的cookie,这样当我重新打开应用程序时,我可以恢复存储在前一个实例中的那些。要初始化alamofire,我使用:letmanager=Alamofire.Manager.sharedInstance我加载cookie的代码是:letcookies=NSHTTPCookie.cookiesWithResponseHeaderFields(headerFields,forURL:URL)Alamofire.Manager.sharedInstance.session.configuration.HTTPCookieStorage?.setCookies(cookies,for

swift - Alamofire - NSURLCache 不工作?

我的缓存设置如下varcacheSizeMemory=20*1024*1024varcacheSizeDisk=100*1024*1024varsharedCache=NSURLCache(memoryCapacity:cacheSizeMemory,diskCapacity:cacheSizeDisk,diskPath:"SOME_PATH")NSURLCache.setSharedURLCache(sharedCache)使用缓存策略创建请求varrequest=NSMutableURLRequest(URL:NSURL(string:"\(baseUrl!)\(path)")!,

swift - Alamofire - NSURLCache 不工作?

我的缓存设置如下varcacheSizeMemory=20*1024*1024varcacheSizeDisk=100*1024*1024varsharedCache=NSURLCache(memoryCapacity:cacheSizeMemory,diskCapacity:cacheSizeDisk,diskPath:"SOME_PATH")NSURLCache.setSharedURLCache(sharedCache)使用缓存策略创建请求varrequest=NSMutableURLRequest(URL:NSURL(string:"\(baseUrl!)\(path)")!,

swift - 使用 alamofire 路由器上传文件

如何使用alamofire路由器上传文件?与之抗争。我也很感兴趣如何使用Alamofire路由器在同一请求中上传文件和参数。谢谢! 最佳答案 我使用以下代码上传图片。对于给定的文件类型,您应该能够相应地调整multipartEncodingblock。letjson:[String:Any]=["key","value"]letimage=UIImage(named:"Something")!guardletimageData=UIImagePNGRepresentation(image)else{//Wecouldn'tconve

swift - 使用 alamofire 路由器上传文件

如何使用alamofire路由器上传文件?与之抗争。我也很感兴趣如何使用Alamofire路由器在同一请求中上传文件和参数。谢谢! 最佳答案 我使用以下代码上传图片。对于给定的文件类型,您应该能够相应地调整multipartEncodingblock。letjson:[String:Any]=["key","value"]letimage=UIImage(named:"Something")!guardletimageData=UIImagePNGRepresentation(image)else{//Wecouldn'tconve

ios - Carthage 安装失败,代码为 65

我正在一台新机器上安装carthage。$brewinstallCarthage[在项目根目录]$emacsCartfile#Alamofiregithub"Alamofire/Alamofire"#SwifyJSONgithub"SwiftyJSON/SwiftyJSON"$迦太基更新***FetchingSwiftyJSON***FetchingAlamofire***CheckingoutAlamofireat"1.2.3"***CheckingoutSwiftyJSONat"2.2.0"***xcodebuildoutputcanbefoundin/var/folders/8n

ios - Carthage 安装失败,代码为 65

我正在一台新机器上安装carthage。$brewinstallCarthage[在项目根目录]$emacsCartfile#Alamofiregithub"Alamofire/Alamofire"#SwifyJSONgithub"SwiftyJSON/SwiftyJSON"$迦太基更新***FetchingSwiftyJSON***FetchingAlamofire***CheckingoutAlamofireat"1.2.3"***CheckingoutSwiftyJSONat"2.2.0"***xcodebuildoutputcanbefoundin/var/folders/8n

swift - 带反斜杠的 JSON 编码

我正在使用Alamofire和SwiftyJSOn来解析JSON输出。它工作得很好,但是有些站点提供带有转义输出的json。我像下面这样使用AlamofireAlamofire.request(.POST,url,parameters:param,encoding:.JSON).responseJSON{(req,res,json,error)invarjson=JSON(json!)网站给我带有转义字符串的JSON结果,因此SwiftyJSON无法对其进行解码。我怎样才能在下面转换{"d":"{\"UniqeView\":{\"ArrivalDate\":null,\"Arrival