小弟最近在开发tweak过程中,需要在SB中创建一个文件,代码如下:
%hook SpringBoard
-(void)applicationDidFinishLaunching: (id)application {
%orig;
NSError *error = nil;
NSString *filePath = [NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"temp.txt"];
NSString *fileContent = @"123";
NSData *data = [fileContent dataUsingEncoding:NSUTF8StringEncoding];
if (![data writeToFile:filePath options:NSDataWritingAtomic error:&error]) {
NSLog(@"lwlwl创建文件失败");
NSLog(@"Error was code: %d - message: %@", errno, error);
}
/*
if (![NSFileManager defaultManager] createFileAtPath:filePath contents:data attributes:nil]) {
NSLog(@"创建文件失败");
}
*/
}
%end
一直无法保存成功,error显示的是权限问题,但是我就是在SB自己的资源文件下创建的下,也没权限吗?求大牛指教~