ITeye博客

NSBundle使用

mcgtts · 2011-09-20 14:09 · objective-c · 移动开发 · Markdown

NSBundle束,是一种特定的文件类型,其中的内容遵循特定的结构。

NSBundle的一个主要作用是 获取Resources文件夹中的资源。

使用主束来获取需要的资源文件:

NSBundle *bundle = [NSBundle mainBundle]; 

NSString *plistPath = [bundle pathForResource:@"statedictionary" ofType:@"plist"];

  

或者简写成一行:

NSString *path = [[NSBundle mainBundle] pathForResource:@"sortednames" ofType:@"plist"]; 

NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。