iOS学习笔记3

2016-04-08  本文已影响19人  蠢萌的L君

Plist文件

    // 获取file在不同机器的文件全部路径
    NSString *file = [[NSBundle mainBundle] pathForResource:@"文件名" ofType:@"格式名"];
    // 如果plist根为array就用array接受,为dictionary就用dictionary接收
    [NSArray arrayWithContentsOfFile:file];

常见问题

懒加载

-(NSArray *)shop{
    if (_shop == nil)
    {
        NSString *file = [[NSBundle mainBundle] pathForResource:@"文件名" ofType:@"格式名"];
        // 如果plist根为array就用array接受,为dictionary就用dictionary接收
        _shop = [NSArray arrayWithContentsOfFile:file];
        
    }
    return _shop;
}

模型

- (instancetype)initWihtDict:(NSDictionary *)dict;
+ (instancetype)shopWithDict:(NSDictionary *)dict;
上一篇下一篇

猜你喜欢

热点阅读