bundle是一个目录。我们的程序是一个bundle. 在Finder中,一个应用程序看上去和其他文件没有什么区别. 但是实际上它是一个包含了nib文件,编译代码,以及其他资源的目录. 我们把这个目录叫做程序的main bundle。
在国际化,自动为我们屏蔽了各种差异;
通常用来获取资源文件路径:
NSString *filePath = [[NSBundle mainBundle] pathForResouse:@"re" ofType:@"xml"];
NSData *data = [[NSData alloc] initWithContentsOfFile:filePath];
读取plist中的内容:
NSString *dataPath = [[NSBundle mainBundle] pathForResource:@"Data" ofType:@"plist"];
self.data = [NSArray arrayWithContentsOfFile:dataPath];