Maybe this is a noob question, i have an NSURL from savePanel, and i want to save the file with such an identifier name. How to change the filename on NSURL?
here’s my save method :
for (int i=0; i<[rectCropArray count]; i++) {
//the code goes on..
CGImageDestinationRef dest = CGImageDestinationCreateWithURL(url, outputType, 1, nil);
if (dest == nil) {
NSLog(@"create CGImageDestinationRef failed");
return NO;
}
CGImageDestinationAddImage(dest, imageSave, (CFDictionaryRef)dictOpts);
//the code goes on..
}
what i really want to do is, add the url filename every loop with i, so the method can save the different file on every loop.
eg: SavedFile1.jpg, SavedFile2.jpg …
thanks.
NSURLhas ainitWithString:relativeToURL:method that you should be able to use for that. If you take the parent directory of the URL, the file name and the extension, you should be able to craft new URLs with relative ease usingURLWithString:relativeToURL:.