从外部项目目录中读取plist文件

时间:2022-03-22 19:00:32

i have a plist file in my project directory. I can read and write in this plist file.

我的项目目录中有一个plist文件。我可以在这个plist文件中读写。

But is this possible to read plist file from outside project directory?

但是这可以从外部项目目录中读取plist文件吗?

my code is to read plist file from project dir:

我的代码是从项目目录中读取plist文件:

if let path = NSBundle.mainBundle().pathForResource("test", ofType: "plist") {
    myDict = NSDictionary(contentsOfFile: path) //mydict is a dictionary type variable
}

1 个解决方案

#1


1  

You can only read files from your bundle or from one of the other sandboxed directories. You could read/write plist files from your documents directory, for example.

您只能从捆绑包或其他沙盒目录中读取文件。例如,您可以从文档目录中读取/写入plist文件。

#1


1  

You can only read files from your bundle or from one of the other sandboxed directories. You could read/write plist files from your documents directory, for example.

您只能从捆绑包或其他沙盒目录中读取文件。例如,您可以从文档目录中读取/写入plist文件。