如何在Swift 3中设置共享URLCache? [英] How to set the shared URLCache in swift 3?

查看:155
本文介绍了如何在Swift 3中设置共享URLCache?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我们在Swift 2中拥有的代码.什么是Swift 3版本?我看不到setShared的替代品.

This is the code we had in Swift 2. What is the Swift 3 version? I don't see a replacement for setShared.

let sharedCache: NSURLCache = NSURLCache(memoryCapacity: 0, diskCapacity: 0, diskPath: nil)
NSURLCache.setSharedURLCache(sharedCache)

推荐答案

此方法在Xcode 8 Beta 4中有效

This works in Xcode 8 Beta 4

    URLCache.shared = sharedCache

这篇关于如何在Swift 3中设置共享URLCache?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆