1
NSString  *imagePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/InAppLibrary"];

NSString *str=[@"/" stringByAppendingFormat:appDelegate_iPad.DrawPicture];
NSString *currentImageName=[imagePath  stringByAppendingFormat:str];

NSData *dataImage = [NSData dataWithContentsOfFile:currentImageName];

这里 NSData 对象 dataImage 为我提供空值,请任何朋友帮助我了解这里有什么问题。

谢谢

4

1 回答 1

0

我认为你的路径是错误的,你应该使用:

  NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES );
  NSString *docPath =  [paths objectAtIndex:0];

  NSString *imagePath = [docPath stringByAppendingFormat:@"/InAppLibrary/%@", appDelegate_iPad.DrawPicture];
  NSData *dataImage = [NSData dataWithContentsOfFile: imagePath ];
于 2012-05-30T13:48:29.750 回答