我很快就秃顶了,需要帮助!
我正在编写一个需要访问目录的应用程序。我希望得到一种形式的路径/用户/我/库/应用程序支持/iPhone模拟器/用户/应用程序/6958D21C-C94B-4843-9EF1-70406D0CA3A3/文档.
然而我的应用程序给了我/用户/我/库/应用程序支持/iPhone模拟器/用户/文档这不是我想要的,因为没有写访问权限。
这是我的代码的彻底精简版本。请注意,您需要查看模拟器中的控制台才能看到输出。我检查了我所知道的所有参考资料,但没有成功改变这种行为。它是一些编译器选项吗?或者我必须在 Info.plist 中更改一些内容?有谁请...
更新:由于一些非常奇怪的原因,我的应用程序没有被沙箱化。为什么?
文件 DirTestAppDelegate.h
#import <UIKit/UIKit.h>
@interface DirTestAppDelegate : NSObject <UIApplicationDelegate>
{
UIWindow *window;
}
@end
文件 DirTestAppDelegate.m
#import "DirTestAppDelegate.h"
@implementation DirTestAppDelegate
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSLog(documentsDirectory);
}
- (void)dealloc
{
[super dealloc];
}
@end
这是配置设置不正确的问题。花了几个小时才修复:-(
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)