草庐IT

Alamofire4

全部标签

ios - 使用 Alamofire (Swift 2) 从 JSON 填充表格 View 单元格

我有以下代码。importUIKitimportAlamofireclassCheHappyTableViewController:UITableViewController,NSURLConnectionDelegate{varhappyHours=[HappyHour]()overridefuncviewDidLoad(){super.viewDidLoad()//LoadthecellelementsloadHappyHourElements()}overridefuncdidReceiveMemoryWarning(){super.didReceiveMemoryWarning

ios - 使用 Alamofire (Swift 2) 从 JSON 填充表格 View 单元格

我有以下代码。importUIKitimportAlamofireclassCheHappyTableViewController:UITableViewController,NSURLConnectionDelegate{varhappyHours=[HappyHour]()overridefuncviewDidLoad(){super.viewDidLoad()//LoadthecellelementsloadHappyHourElements()}overridefuncdidReceiveMemoryWarning(){super.didReceiveMemoryWarning

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

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

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