Search code examples
xcodepathdirectorynsbundle

NSBundle Not Working


NSBundle outputs the old name of my app: "/var/mobile/Applications/0E1638D2-5B9C-4A1F-8ED2-5F8ADF55D3F6/distributedLCA.app" but I renamed the project but it still prints out that old .app name. Is there a way to fix this?

My code:

[[NSBundle mainBundle] resourcePath]

Solution

  • After some lengthy google searching, I came across this bit of code that fixed my problem. Instead of writing to the .app I write to the documents of the device:

    NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *docStorePath = [searchPaths objectAtIndex:0];
    NSString *filePath = [docStorePath stringByAppendingPathComponent:@"/YOUR_FILE.txt"];``