NSBuddle mainBuddle

一.获取图片

  1.   NSString *path = [[NSBuddle mainBuddle] pathForResource:@"resourceName" oftype@"resourceType"];

       UIImage *image = [[UIImage imageWithContentsOfFile:path];

 

  2.   UIImage *image = [UIImage imageNamed:@"imageName"];

二.获取plist文件

 

NSString*path=[[NSBundle mainBundle]pathForResource:self.fileName ofType:@"plist"];

    self.dataArray=[NSArray arrayWithContentsOfFile:path];

 

  NSArray *array =[[NSArray alloc]initWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"name"ofType:@"plist"]];

  NSDictionary *dict=[array objectAtIndex:index];//将plist文件中的内容转换成字典

posted @ 2014-08-31 12:58  ZLY的日志  阅读(127)  评论(0编辑  收藏  举报