2012-05-30 80 views
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爲我提供了空值,任何好友幫我關於這裏的錯誤。iPhone中的NSData對象

感謝

+0

什麼是你想反正做什麼? – woz

回答

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 ]; 
+0

謝謝兄弟你是對的。 –

+0

如果我的答案是正確的,請接受:逐步指導「如何接受答案工作」http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235 – CarlJ