Reputation: 512
I have a plist in my Xcode project's resource folder but on physical drive it's in the top folder of my project. I want to read and write from this same file. Using NSBundle reads it properly and gives no problem. I'm using this code to read file path:
NSString *thePath = [[NSBundle mainBundle] pathForResource:@"MyFile" ofType:@"plist"];
but i think NSBundle doesn't allow writing back and so it didn't work when i tried to write back the file. Using the following code creates/ updates file using application path
NSArray *pathArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDirectory, YES);
NSString * docsDirectory = [pathArray objectAtIndex:0];
NSString *filePath = [docsDirectory stringByAppendingPathComponent:@"MyFile.plist"];
but for now, I need to write on internal file. Any solution to access it? Besides, I've tried giving path from my working directory to project directory. It also doesn't work.
Upvotes: 0
Views: 2639
Reputation: 73936
It's not NSBundle
that doesn't support writing, it's iOS itself. iOS will not let your app write to its own bundle.
Upvotes: 1