开发者

File write issue

开发者 https://www.devze.com 2023-03-28 10:45 出处:网络
I have the following code.It does not generate an error but my file does not get updated either. if([cDatecompare:Today] == NSOrderedAscending){

I have the following code. It does not generate an error but my file does not get updated either.

if([cDate  compare:Today] == NSOrderedAscending){

     NSLog(@"%@", [NSString stringWithFormat:@"%@, 0", Today]);
     if(![[NSString stringWithFormat:@"%@, 0", Today] writeToFile:filePath atomically:TRUE])
           开发者_如何学C NSLog(@"writeToFile failed");  
}


You can't write to the Bundle. it's code signed and read-only. You need to use the documents folder.

use this to get to the document folder and you chave write permissions there.

NSArray *basePath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
0

精彩评论

暂无评论...
验证码 换一张
取 消