gpt4 book ai didi

ios - WatchKit 扩展可以从 NSCache 访问数据吗?

转载 作者:行者123 更新时间:2023-11-29 02:22:25 25 4
gpt4 key购买 nike

我知道我们可以从 NSFileManager 获取数据,以便将我们的应用程序中的图像传输到我们的 WatchKit 扩展中 - 但我们一直在使用 NSCache 在我们的 iOS 中缓存图像应用程序。有没有办法将我们的 WatchKit 扩展连接到来自 NSCache 的图像?

这是Apple's documentation说:

At runtime, you share files between processes by reading and writing those files in the shared container directory. To access the container directory, use the containerURLForSecurityApplicationGroupIdentifier: method of NSFileManager to retrieve the base URL for the directory. Use the provided URL to enumerate the directory contents or create new URLs for files in the directory.

To share preferences data between apps, create an NSUserDefaults object using the identifier of the shared group. The initWithSuiteName: method of NSUserDefaults creates an object that allows access to the shared user defaults data. Both processes can access this data and write changes to it.

乍一看,好像不行,不可能使用 NSCache 在我们的 iOS 应用程序和我们的 WatchKit 应用程序之间共享图像 - 但如果有人有办法做到这一点,我会很想知道。

最佳答案

不幸的是,您无法访问 iOS 应用程序及其扩展程序之间的共享 NSCache,因为它们每个都有自己的内存空间。

关于ios - WatchKit 扩展可以从 NSCache 访问数据吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27975370/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com