首页 > 代码库 > Xcode--NSBundle

Xcode--NSBundle

NSBundle
一.获取图片
  1.   NSString *path = [[NSBundle mainBundle] pathForResource:@"resourceName" ofType:@“resourceType"];
       UIImage *image = [[UIImage imageWithContentsOfFile:path];

  2.   UIImage *image = [UIImage imageNamed:@"imageName"];
二.获取plist文件
  NSArray *array =[[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"name"ofType:@"plist"]];
  NSDictionary *dict=[array objectAtIndex:index];//将plist文件中的内容转换成字典

Xcode--NSBundle