OC读取plist文件

OC读取plist文件:

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{

    @autoreleasepool {
        
        NSArray * arr = [NSArray arrayWithContentsOfFile:@"/Users/zl201/Desktop/NSDictionaryHomework/ProvincesAndCities.plist"];
        //使用绝对路径
        
        for (NSDictionary *dic in arr) {
            NSArray * cities = [dic objectForKey:@"Cities"];
            
            for (NSDictionary * city in cities) {
                NSString * cityName = [city objectForKey:@"city"];
                NSString * lat = [city objectForKey:@"lat"];
                NSString * lon = [city objectForKey:@"lon"];
                NSLog(@"%@ lat = %@ lon = %@",cityName,lat,lon);
            }
        }

    }
    return 0;
}


你可能感兴趣的:(OC读取plist文件)