- (void)video:(NSString *)videoPath didFinishSavingWithError:(NSError *)error contextInfo:(NSString *)contextInfo{
NSLog(@"didFinishSavingWithError--videoPath in temp directory:%@",contextInfo);
NSString *file,*latestFile;
NSDate *latestDate = [NSDate distantPast];
NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:[[contextInfo stringByDeletingLastPathComponent]stringByDeletingLastPathComponent]];
// Enumerate all files in the ~/tmp directory
while (file = [dirEnum nextObject]) {
// Only check files with MOV extension.
if ([[file pathExtension] isEqualToString: @"MOV"]) {
NSLog(@"latestDate:%@",latestDate);
NSLog(@"file name:%@",file);
NSLog(@"NSFileSize:%@", [[dirEnum fileAttributes] valueForKey:@"NSFileSize"]);
NSLog(@"NSFileModificationDate:%@", [[dirEnum fileAttributes] valueForKey:@"NSFileModificationDate"]);
// Check if current jpg file is the latest one.
if ([(NSDate *)[[dirEnum fileAttributes] valueForKey:@"NSFileModificationDate"] compare:latestDate] == NSOrderedDescending){
latestDate = [[dirEnum fileAttributes] valueForKey:@"NSFileModificationDate"];
latestFile = file;
NSLog(@"***latestFile changed:%@",latestFile);
}
}
}
// The Video path.
latestFile = [NSTemporaryDirectory() stringByAppendingPathComponent:latestFile];
NSLog(@"This Is The Recent Video:%@",latestFile);
}
Затем откройте консоль, чтобы просмотреть результаты :-) надеюсь, это поможет