NSFileWrapper是否将所有内容加载到内存中? [英] Does NSFileWrapper load everything into memory?

查看:482
本文介绍了NSFileWrapper是否将所有内容加载到内存中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个 NSFileWrapper 目录。该目录由多个级别的目录和文件组成。有些文件很大。所有这些文件是否已加载到内存中,或者是否被延迟加载?

Lets say I have an NSFileWrapper directory. This directory is made up of several levels of directories and files. Some of the files are large. Are all these files loaded into memory, or are they lazily loaded?

如果将它们加载到内存中,是否有 NSFileWrapper的替代方法具有类似的功能,不会将文件加载到内存中?我可以挂钩的东西 UIDocument

If they are loaded into memory, are there any alternatives to NSFileWrapper with similar functionality that won't load files into memory? Something I can hook into UIDocument?

这是一个基于文档的应用程序,它使用与iCloud同步的 UIDocument 。文档可以在其中嵌入图像和视频。每个图像/视频都有一个HTML文档中显示的预览图像(缩略图)。全尺寸图像或视频不应该加载到内存中,而是按需加载。

This is for a document based application, which uses UIDocument's that are synced with iCloud. A document can have images and videos embedded inside it. Each image/video has a preview image (thumbnail) that is shown in an HTML document. The full size images or videos shouldn't be loaded into memory, but rather loaded on demand.

我还需要一种方法来添加资源而不将其加载到内存中。像initWithAsset:(ALAsset *)这样的东西是理想的。

I also need a way to add a resource without loading it into memory. Something like "initWithAsset:(ALAsset *)" would be ideal.

推荐答案

从文档中不完全清楚,但我' m 99%肯定 NSFileWrapper 将内存映射所有内容 NSFileWrapper 的主要用例是将文件嵌入到文档中,您可能始终需要访问该文件。

It's not totally clear from the documentation, but I'm 99% positive that NSFileWrapper will memory-map everything. The main use case for NSFileWrapper is to embed files inside documents, where you'd presumably need access to said file at all times.

您正在尝试使用文件包装器?我假设如果您要映射整个目录,则不一定要将媒体嵌入到文档中,但也许我错了。如果您可以更多地谈论您的用例,那么这将影响您可能采用的替代方案。

What are you trying to use the file wrapper for? I assume if you're mapping an entire directory it's not necessarily to embed media inside a document, but perhaps I'm mistaken. If you maybe talk a bit more about your use case, as that will influence what alternatives you might go for.

这篇关于NSFileWrapper是否将所有内容加载到内存中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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