IOS NSBundle使用(访问文件夹)

NSBundle的相关信息

1.一个NSBundle代表一个文件夹,利用NSBundle能访问对应的文件夹

2.利用mainBundle就可以访问软件资源包中的任何资源

3.模拟器应用程序的安装路径:

/Users/aplle/资源库/Application Support/iPhone Simulator/7.1/Applications

代码:访问plist文件

        NSString *path=[[NSBundle mainBundle]pathForResource:@"statuses.plist" ofType:nil];

代码 :访问Xib

+(instancetype)cellWithTableView:(UITableView *)tableView{

    static NSString *ID=@"tg";
    MJtgCell *cell=[tableView dequeueReusableCellWithIdentifier:ID];
    if(cell==nil)
    {
        //从xib中加载cell
        cell=[[[NSBundle mainBundle]loadNibNamed:@"MJtgCell" owner:nil options:nil]lastObject];
    }
    return cell;
    
}
原文地址:https://www.cnblogs.com/liuwj/p/6476813.html