Change file names of images?
I want to change the file开发者_如何学JAVA names of images in my app, can i do this?
If the image is inside your NSBundle, then the answer is No. If you copy an image from ALAssetsLibrary you can name it whatever you like.
If it is in your NSBundle and you'd like to create a copy of the same image name, you can do that by loading the NSData and saving it with a different name. That just uses up extra space though.
Why are you trying to change the name of an image to begin with? If you needed to, you can create an NSMutableDictionary and a special function which takes a "filename" and returns the name of the actual image file in your NSBundle.
For example if you had a file named "MyImage.png" which part of your program thinks is actually called "ThatCoolPicture.png", you can load it like this: UIImage *img = [UIImage imageNamed:[self nameForPseudoname:@"ThatCoolPicture.png"]];
In this case nameForPseudoname takes a "nickname" and returns the real name.
Hope this helps!
精彩评论