Modify a file URL by removing or appending a path
suggest changeURLByDeletingPathExtension
If the receiver is a root path, the result is a copy of the original URL. If the URL has multiple path extensions, only the last one is removed.
URLByAppendingPathExtension:
Returns a new URL made by appending a path extension to the original URL.
Example:
NSUInteger count = 0;
NSString *filePath = nil;
do {
NSString *extension = CFBridgingRelease(UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)AVFileTypeQuickTimeMovie, kUTTagClassFilenameExtension));
NSString *fileNameNoExtension = [[asset.defaultRepresentation.url URLByDeletingPathExtension] lastPathComponent];
NSString *fileName = [NSString stringWithFormat:@"%@-%@-%lu", fileNameNoExtension, AVAssetExportPresetLowQuality, (unsigned long)count];
filePath = NSTemporaryDirectory();
filePath = [filePath stringByAppendingPathComponent:fileName];//Appending is used
filePath = [filePath stringByAppendingPathExtension:extension];
count++;
} while ([[NSFileManager defaultManager] fileExistsAtPath:filePath]);
NSURL *outputURL = [NSURL fileURLWithPath:filePath];
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents