Changing App Name with plist data files

时间:2016-02-03 02:59:06

标签: ios objective-c

I currently have an app that uses a plist (stored locally) to save data. (The app is like an address book app). The code I use involving the plist is below:

- (NSString *)infoDataFileName
{
NSError *err = nil;
NSURL *dir = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSAllDomainsMask appropriateForURL:nil create:YES error:&err];


NSString *path = [[dir path]  stringByAppendingString:@"/infoData.plist"];


return path;
}

However, I just changed the name of my app. I redownloaded the app onto my phone, and none of my original data is showing up. How can I make the data from the original plist show up in the new plist?

Thanks so much!

2 个答案:

答案 0 :(得分:0)

When I changed my app's name, I also changed the Bundle ID, which effectively created an entirely new app, independent of the old version. I changed the Bundle ID back to what it used to be, and the problem was solved.

You can view/change your Bundle ID in Project Overview > General > Identity > Bundle Identifier.

答案 1 :(得分:0)

If you are creating new app, then you didn't face this problem. You just need to copy the "infoData.plist" file to your project and call your method.

If you changing name of your project and search your previous project name and replace with new project name.

May this helps.