ios NSBundle 程序包路径

来源:互联网 发布:ikev2搭建 ubuntu 编辑:程序博客网 时间:2024/06/12 18:51

- (void)mainBundleTest{


    //使用NSBundle获取该应用自包含的指定资源文件路径

    NSString *filePath = [[NSBundlemainBundle]pathForResource:@"books"ofType:@"txt"];

    //使用指定文件的内容来初始化NSString

    NSString *content = [NSStringstringWithContentsOfFile:filePath encoding:NSUTF8StringEncodingerror:nil];

    

    //textLabel.text = content ;

    NSLog(@"------%@",content);

}

输出内容:

2015-04-14 10:37:33.413 RTSW[956:43391] ------ssssssss

wwee


mainBundleTest


我爱共产党


0 0