Modifying and Converting a File URL with removing and appending path

suggest change

1. URLByDeletingPathExtension:

If the receiver represents the root path, this property contains a copy of the original URL. If the URL has multiple path extensions, only the last one is removed.

2. 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 = ( NSString *)UTTypeCopyPreferredTagWithClass(( CFStringRef)AVFileTypeQuickTimeMovie, kUTTagClassFilenameExtension);
         NSString *fileNameNoExtension = [[asset.defaultRepresentation.url URLByDeletingPathExtension] lastPathComponent];//Delete is used
         NSString *fileName = [NSString stringWithFormat:@"%@-%@-%u",fileNameNoExtension , AVAssetExportPresetLowQuality, 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];

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


NSURL:
*Modifying and Converting a File URL with removing and appending path

Table Of Contents