gpt4 book ai didi

iphone - 从 iPhone 登录 : where is the file?

转载 作者:行者123 更新时间:2023-11-28 22:49:21 24 4
gpt4 key购买 nike

我正尝试通过此代码从我的 iPhone 应用程序在我的 MacOS FS 上创建一个文件

 [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) ];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [paths objectAtIndex:0];
path = [path stringByAppendingPathComponent: @"log.txt"];
NSFileHandle *output = [NSFileHandle fileHandleForWritingAtPath:path];
if(output == nil) {
[[NSFileManager defaultManager] createFileAtPath:path contents:nil attributes:nil];
output = [NSFileHandle fileHandleForWritingAtPath:path];
} else {
[output seekToEndOfFile];
}

我猜代码没问题,因为它在由模拟器执行时可以正常工作。但是,从 iPhone 执行时,我实际上看不到文件的创建位置。如果我打印我得到的路径

/var/mobile/Applications/XXX-XXXX-XXX-XXX/Documents/log.txt

最佳答案

在模拟器上,您应该在以下位置找到它们:/Users/loginname/Library/Application Support/iPhone Simulator/5.1/Applications/594931F3-B9EF-4B2C-833D-76C2DCC61C6B/Documents。您可以从 Finder 转到此位置,方法是选择“前往”菜单项,按住 Option 键,然后选择“库”。

注意:在上面的路径中填写您自己的登录名和设备ID。

如果您在设备上,则可以使用管理器(选择“窗口”|“管理器”)使用 XCode 将文件复制到您的 Mac。突出显示应用程序(当然是在执行后),然后有一个选项可以复制文件。您无权直接访问设备文件系统。

您还可以使用 NSLog(),它将调试信息发送到 XCode 中的输出窗口。

编辑:添加了有关如何显示库文件夹的详细信息。

关于iphone - 从 iPhone 登录 : where is the file?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12323194/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com