Document文件路径,图片路径

 //方法2 iOS4.0版本以下的可以使用该方法获取url

C代码   收藏代码
  1. - (NSURL *)applicationDocumentsDirectory_Old {  
  2.     NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);//程序文件夹主目录  
  3.         NSString *documentsDirectory = [paths objectAtIndex:0];//Document目录  
  4.         NSString *storePath = [documentsDirectory stringByAppendingPathComponent:@"Data.sqlite"];  
  5.     NSURL *storeURL = [NSURL fileURLWithPath:storePath];  
  6.     return storeURL;  
  7. }      

 //方法3 获取文件中的Image地址及UIImage

C代码   收藏代码
  1. NSString*imagePath = [[[NSBundlemainBundle] resourcePath] stringByAppendingPathComponent:@"Image"];  
  2. imagePath = [artistImagePath stringByAppendingPathComponent:@"bg"];  
  3. imagePath = [artistImagePath stringByAppendingPathComponent:@"bg.png"];  
  4. NSLog(@"%@", imagePath);  
  5. UIImage* pic =  [UIImage imageWithContentsOfFile: imagePath];  
  6.   
  7. //输出:/Users/test/Library/Application Support/iPhone Simulator/4.1/Applications/Test.app/Image/bg/bg.png  

猜你喜欢

转载自lizhuang.iteye.com/blog/2101613