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);
精彩评论