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;
}


上一篇:JavaScript中this绑定详解


下一篇:飞天加速计划·高校学生在家实践