How to read data structure from .plist file into NSArray

后端 未结 8 835
故里飘歌
故里飘歌 2020-11-28 20:15

I was creating a data structure manually using the following:

NSDictionary* league1 = [[NSDictionary alloc] initWithObjectsAndKeys: @\"Barclays Premier Leagu         


        
8条回答
  •  北海茫月
    2020-11-28 20:34

    NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"league" ofType:@"plist"];
    contentDict = [NSDictionary dictionaryWithContentsOfFile:plistPath];
    

    That answer is correct - are you sure that your file is in the app? Did you add it to your project, and check to see if it gets copied into your app bundle? If not, it might be the file was not added to the target you are building, an easy mistake to make especially if you have multiple targets.

提交回复
热议问题