plist in Xcode creation

后端 未结 4 652
天涯浪人
天涯浪人 2020-12-11 23:46

When I am creating a simple application for plist shown in below link:

http://iosdevelopertips.com/data-file-management/reading-a-plist-into-an-nsarray.html

4条回答
  •  鱼传尺愫
    2020-12-12 00:08

    The problem could be

    1. The file doesn't exist at specified path, you get nil in array2.
    2. The file exists but it cannot be read correctly, due to some format corruption, and you get nil in array2 too.
    3. The file exists and its format is correct, but there are no values in, you get an empty array.

    When using NSString *path = [[NSBundle mainBundle] pathForResource:@"DrinkArray" ofType:@"plist"];, it assumes you have a correctly formed plist file named "DrinkArray" ('DrinkArray.plist'), inside your app bundle. Make sure your file is also copied into the app bundle (check this in Xcode, click on your project, then Build phases, your file should appear in the 'Copy Bundle Ressources').

    I guess you get nilas the path to the file, and therefore in array2. Try to log your path string to check it.

提交回复
热议问题