本文介绍了我的应用程序应该在iOS上存储大量的PDF文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我撰写的iOS iPad应用程式会从网路上下载数百个大型PDF档案,并将它们储存在iPad上供离线使用。



地方将它们存储在iPad上?本地文件系统,核心数据还是其他地方?我计划使用核心数据用于索引和搜索机制(使用缩略图等),并且只有在用户特别请求完整文档时才能访问PDF文档。

解决方案

这样做的最好的地方是文档目录或缓存目录。 的文件应该是用户生成的内容,所以我相信这不是你要找的。

相反,我认为您应该使用缓存目录,您可以使用此方法访问:

   - (NSString *)cacheDirectory {
{
NSArray * pathList = NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask,YES);
NSString * path = [pathList objectAtIndex:0];
return path;
}

请注意,系统,如果你没有足够的空间在设备上。根据我的经验,这几乎不会发生,但您可能希望将您的文档存储在目录的子目录中,而不是缓存,如果你想绝对,绝对确定

在此情况下,您必须设置不备份 $ c
$ b

请参阅(需要开发人员帐户)以获取官方信息。


I am writing an iOS iPad app that will download several hundred large PDF files from the web and cache them on the iPad for offline use.

Where is the best place to store them on the iPad? The local file system, core data, or some other place? I am planning to use core data for an indexing and search mechanism (using thumbnail images etc), and will only access the PDF docs when a user specifically requests the full document.

解决方案

The best place to do so is either the Documents directory or the Cache directory. Documents in the Documents directory are supposed to be user-generated content, so I believe this is not what you're looking for.

Instead, I think you should use the Cache directory, which you can access using this method :

- (NSString *)cacheDirectory {
{
    NSArray *pathList = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
    NSString *path    = [pathList objectAtIndex:0];
    return path;
}

Note that the Cache directory can be emptied by the system if you don't have enough space on the device. In my experience this almost never happens, but you might want to store your documents in a subdirectory of the Library directory other than Cache if you want to be absolutely, absolutely sure that the files never ever get deleted.

In this case, you have to set the do not backup flag on both the directory and the files, or else your app will be rejected.

See the Apple guidelines (requires a developper account) for official information.

这篇关于我的应用程序应该在iOS上存储大量的PDF文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 19:39