gpt4 book ai didi

ios - 如何在 objective-c 中开辟一条路径?

转载 作者:行者123 更新时间:2023-11-29 03:43:35 24 4
gpt4 key购买 nike

我正在使用 Objective C (IOS),我发现了以下代码:

Person *aPerson = <#Get a Person#>;
NSString *archivePath = <Path for the archive#>;
BOOL success = [NSKeyedArchiver archiveRootObject:aPerson toFile:archivePath];

我想知道将文件保存在文档目录中的 archivePath 应该是什么。

谢谢

最佳答案

要找出存档路径:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0]; //Get the docs directory
NSString *archivePath = [documentsPath stringByAppendingPathComponent:@"Person"];

关于ios - 如何在 objective-c 中开辟一条路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18027775/

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