Not able to write to Plist

前端 未结 2 998
孤独总比滥情好
孤独总比滥情好 2020-12-21 23:02

I have a very basic question about how to write to a plist. I added a \"Here.plist\" file to my resources folder. The following is my code:

NSString *path =          


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-21 23:33

    I suspect your problem is due to the fact that you can't write to the application bundle, only to your application's document store.

    To obtain a path to the document store, use:

    NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *docStorePath = [searchPaths objectAtIndex:0];
    
    NSString *filePath = [docStorePath stringByAppendingPathComponent:@"XXXXX"];
    

提交回复
热议问题