Search code examples
objective-cplist

This loading plist is wrong?


NSString *levelPlist = [[NSBundle mainBundle]pathForResource:[NSString stringWithFormat:@"Level%d", level] ofType:@"plist"];
NSDictionary *levelData = [NSDictionary dictionaryWithContentsOfFile:levelPlist];

When I load plist like this, levelPlist is just a (null). stringWithFormatsyntax is wrong?


Solution

  • As always when debugging break the problem down,first get the file name, then loading the file contents.

    Then NSLog() the file name and verify that a file with that name exists directly in the app bundle. Do that by actually looking in the app file.

    Safe bet: It the file with the formatted names and extension does not exist directly in the app bundle.

    Possibilities:

    1. The file you are trying to read exists in the app's Documents directory.
    2. The file name is not what you think.
    3. There is a case difference, iOS has a case sensitive file system, that is different than OSX.