获取核心数据中文件的路径 [英] Get path to file in Core Data

查看:106
本文介绍了获取核心数据中文件的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以获取存储在Core Data中的文件的路径,还是只能提取文件本身?我需要存储为Core Data中NSData属性的文件的路径,而不是数据库本身.一些iOS功能通常要求提供NSURL而不是文件本身,而且我还没有弄清楚如何将其与Core Data结合使用.

Is it possible to get the path to files stored inside Core Data, or can I only extract the file itself? I need the path to files stored as NSData attribute in Core Data, not the database itself. Some iOS features often ask for an NSURL rather than the file itself, and I have yet to figure out how to combine this with Core Data.

推荐答案

如果使用SQLite,则数据库内部没有文件".该数据库是一个文件.

There are no "files" inside of the database if you are using SQLite. The database is a single file.

如果要在数据库中存储二进制数据,则无法直接访问其下的文件(即使假设您使用外部存储作为选择).

If you are storing binary data in your database then there is no direct way to get to the file under it (that is even assuming you are using external storage as an option).

如果要直接访问核心数据下SQLite数据库内部的文件,则需要将其自己写到另一个文件中.

If you want direct file access to something inside of the SQLite database under Core Data then you are going to need to write it out yourself to another file.

这篇关于获取核心数据中文件的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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