我正在尝试直接在iCloud文件夹中创建一个文件,当我尝试对iCloud文件夹进行fopen时,我正面临着这一点,总是返回0x0
有没有这样做?我知道我应该使用UIDocument或各种协议,但我只是想要一个简单的方法来访问该文件夹,就像普通文件夹一样。
FILE* file;
NSURL tmp = [ubiq URLByAppendingPathComponent:@"Documents"];
char* folder = (char*) [[tmp absoluteString] fileSystemRepresentation];
sprintf(folder, "%s/file1.txt", folder);
file = fopen(folder, "rw+");
fprinf(file, "%s", "this is just an example");
fclose(file);
我还手动尝试了以下文件夹:
file://localhost/private/var/mobile/Library/Mobile%20Documents/XXXXXX~com~name~app/Documents/file1.txt
//localhost/private/var/mobile/Library/Mobile%20Documents/XXXXXX~com~name~app/Documents/file1.txt
/private/var/mobile/Library/Mobile%20Documents/XXXXXX~com~name~app/Documents/file1.txt
/var/mobile/Library/Mobile%20Documents/XXXXXX~com~name~app/Documents/file1.txt
/var/mobile/Library/Mobile%20Documents/XXXXXX.com.name.app/Documents/file1.txt
/var/mobile/Library/Mobile Documents/XXXXXX~com~name~app/Documents/file1.txt
/var/mobile/Library/Mobile Documents/XXXXXX.com.name.app/Documents/file1.txt
由于fopen()函数调用,所有这些都返回了0x0;
提前谢谢。
PD:我已经使用NSFileManager类成功创建了一个文件。