zoukankan      html  css  js  c++  java
  • NSBundle 的使用

    NSBundle 读取图片 plist text

        NSBundle *mainbundle=[NSBundle mainBundle];
        //使mainBundle 对象获取图片的路径
        NSString *imagePath=[mainbundle pathForResource:@"coffe" ofType:@"png"];
        //使用mainBundle 对象获取到 plist 文件的路径
        NSString *plistPath=[mainbundle pathForResource:@"testplist" ofType:@"plist"];
        //使用mainbundle 对象获取到 TXT 文件路径;
        NSString *txtPath=[mainbundle pathForResource:@"testText" ofType:@"txt"];

     处理上面路径;

    //处理以上路径的资源
        //imagePath
        UIImage *image=[[UIImage alloc] initWithContentsOfFile:imagePath];
        //plistPath 将plist 文件的内容读到字典中去;
        NSMutableDictionary *data=[[NSMutableDictionary alloc] initWithContentsOfFile:plistPath];
        NSLog(@"%@",data);
    
        //textpath 将text 文件内容输出到字符串中
        NSString *txtcontents=[[NSString alloc] initWithContentsOfFile:txtPath encoding:NSUTF8StringEncoding error:nil];

    通过路径获取到APP的信息如 版本号 ;

        NSDictionary *dicAppInfo=[[NSBundle mainBundle] infoDictionary];
        NSString *AppName=[dicAppInfo objectForKey:@"CFBundleDisplayName"];
        NSString *AppVersion=[dicAppInfo objectForKey:@"CFBundleShortVersionString"];
        NSString *AppBuild=[dicAppInfo objectForKey:@"CFBundleVersion"];
        
        NSLog(@"APP应用的名称:%@",AppName);
         NSLog(@"APP应用的版本号为:%@",AppVersion);
         NSLog(@"APP应用的build版本号为:%@",AppBuild);
  • 相关阅读:
    JS-OO-数据属性,访问器属性
    下载php扩展笔记
    php字符串笔记
    include、require、include_once和require_once理解
    http协议笔记
    Git中三种文件状态及其转换
    git add 命令
    / 直接用就可以了 想用,需要用\来转义
    $_POST 变量以及$GLOBALS['HTTP_RAW_POST_DATA']
    Python multiprocessing
  • 原文地址:https://www.cnblogs.com/xieyier/p/4194219.html
Copyright © 2011-2022 走看看