Plist Array to NSArray no objects

后端 未结 2 379
眼角桃花
眼角桃花 2020-12-18 16:34

So I\'ve searched, and read and have done this successfully before, but am running into a problem with this one.

I have a plist that is an array of strings. I get n

相关标签:
2条回答
  • 2020-12-18 16:57
    NSString *plistPath = [self copyFileToDocumentDirectory:plistFileName];
    NSDictionary *plistContents=[[NSDictionary alloc] initWithContentsOfFile:plistPath];
    
    [plistPath release];
    return  plistContents;
    
    0 讨论(0)
  • 2020-12-18 17:23

    PLists are dictionaries at their heart (notice the <dict> tag). Read the file into an NSDictionary, then ask the dictionary for the array using objectforKey: method and the Root key.

    NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:plistPath];
    _brands = [dict objectForKey:@"Root"];
    
    0 讨论(0)
提交回复
热议问题