开发者

File write issue

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜