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

NSBundle 的使用的更多相关文章

  1. iOS在线更新framework,使用NSBundle动态读取

    官方文档:https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/LoadingCode/Tasks/Loadin ...

  2. iOS 整理笔记 获取手机信息(UIDevice、NSBundle、NSLocale)

    /*    iOS的APP的应用开发的过程中,有时为了bug跟踪或者获取用反馈的需要自动收集用户设备.系统信息.应用信息等等,这些信息方便开发者诊断问题,当然这些信息是用户的非隐私信息,是通过开发ap ...

  3. NSBundle

    属性: .使用类方法创建一个NSBundler对象 + (NSBundle *)mainBundle; eg:[NSBundle mailBundle]; .使用路径获取一个NSBundle 对象,这 ...

  4. -[NSBundle initWithURL:]: nil URL argument'

    今天早上同事突然跟我说趣拍的SDK不能用了,一调用就crash,我一听就纳了闷了,原来好好的啊. 然后就开始查呗,马上就要上线了,不搞好,老大会不会杀了我... 搞个全局断点,就停在了一堆我看不懂的界 ...

  5. iOS的UIDevice,NSBundle,NSLocale

    iOS的APP的应用开发的过程中,有时为了bug跟踪或者获取用反馈的需要自动收集用 户设备.系统信息.应用信息等等,这些信息方便开发者诊断问题,当然这些信息是用户的非隐私信息,是通过开发api可以获取 ...

  6. NSBundle常用方法及解释

    1.使用类方法创建一个NSBundler对象+ (NSBundle *)mainBundle;eg:[NSBundle mailBundle];2.使用路径获取一个NSBundle 对象,这个路径应该 ...

  7. NSBundle控件和UIImageView和UIButton区别

    1.NSBundle 1> 一个NSBundle代表一个文件夹,利用NSBundle能访问对应的文件夹 2> 利用mainBundle就可以访问软件资源包中的任何资源 3> 模拟器应 ...

  8. iOS [[NSBundle mainBundle] pathForResource:@"" ofType:@""]无法获取到文件

    将一个文件导入到工程中后,用[[NSBundle mainBundle] pathForResource:@"" ofType:@""]来获取到该文件时,一直无 ...

  9. iOS- Could not find a storyboard named 'Main' in bundle NSBundle

    1.删掉工程中main.storyboard 后要删除plist文件中对应的键值,否则会报如下错误: Could not find a storyboard named 'Main' in bundl ...

  10. NSBundle/其他Bundle的获取

    #define D_SharkItOffViewControllerBundleName @"SharkItOffViewController.bundle" //套装名称 //其 ...

随机推荐

  1. Shell Python 日期和时间戳的互相转换

    一.初衷: 很多时候,时间的存储都是时间戳格式,如果需要展示就要转化成标准格式日期.也许会需要date和timestamp互转. 二.方法: 1.Shell下对date和timestamp的互转,是通 ...

  2. 键盘--android 隐藏系统键盘

    . -----------------------------------------已验证----------------------------------- public static void ...

  3. JDK动态代理与Cglib库

    JDK动态代理 代理模式是常用的java设计模式,他的特征是代理类与委托类有同样的接口,代理类主要负责为委托类预处理消息.过滤消息.把消息转发给委托类,以及事后处理消息等.代理类与委托类之间通常会存在 ...

  4. Altium Designer /DXP无网络铺铜:

    有的设计者在PCB加工的时候会删除网络以便为了保护.但如果后续在无网络PCB上进行修改时就不叫麻烦,没有网络连铺铜都无法进行.一般手动添加网络只对要铺铜的地网络进行,其它的要修改者自己确保版图的正确性 ...

  5. JAVA 创建类,使用类

    一.创建类: Test.java //定义类 public class Test{ //属性 String name; String gender; int age; //方法,无参无返回 publi ...

  6. Intellisense for Xrm.Page in CRM 2011

    Intellisense for Xrm.Page in CRM 2011 In CRM 2011 javascripts for crm forms can be stored externally ...

  7. 可以获取客户端ip的API

    http://www.ip138.com/ip2city.asp http://www.bliao.com/ip.phtml http://www.whereismyip.com/ http://ww ...

  8. Sqlserver中存储过程,触发器,自定义函数

    Sqlserver中存储过程,触发器,自定义函数: 1. 触发器:是针对数据库表或数据库的特殊存储过程,在某些行为发生的时候就会被激活 触发器的分类: DML触发器:发生在数据操作语言执行时触发执行的 ...

  9. isAnagram

    /*Given two strings s and t, write a function to determine if t is an anagram of s. For example, s = ...

  10. How to Modify Public Network Information including VIP in Oracle Clusterware (文档 ID 276434.1)

    APPLIES TO: Oracle Database - Enterprise Edition - Version 11.2.0.3 to 12.1.0.2 [Release 11.2 to 12. ...