How to read data structure from .plist file into NSArray

后端 未结 8 840
故里飘歌
故里飘歌 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:52

    If the file is not added in the resources folder and only placed in your documents directory. You can do this

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *path = [documentsDirectory stringByAppendingPathComponent:@"file.plist"];
    NSMutableArray *arrContentsplist = [[NSMutableArray alloc] initWithContentsOfFile:path];
    

提交回复
热议问题