Iphone : Problem regarding image Stored in Document Directory?
In a App. i am saving the images from server in Document Directory.
In Database that images are came as "image4_12:19:27.png"
in documents directory folder that images stored as "image4_12/19/27.png"
开发者_如何转开发How that image convert "image4_12:19:27.png" to "image4_12/19/27.png" in Document Directory.
What should i do?
You can split the file name into parts separated by :
and then later append them.
NSString * fileName = @"image4_12:19:27.png";
NSArray * components = [fileName componentsSeparatedByString:@":"];
NSString * relativeFilePath = [components componentsJoinedByString:@"/"];
NSString * absoluteFilePath = [documentsDirectory stringByAppendingPathComponent:components];
where documentsDirectory
is the path to the documents directory.
精彩评论