0

I can get the .MOV file with the Image Picker, but how can I find the location it was taken at and the time it was taken?

My image picker: - (void) imagePickerController: (UIImagePickerController *) picker didFinishPickingMediaWithInfo: (NSDictionary *) info {

NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
[self dismissViewControllerAnimated:NO completion:nil];

// Handle a movie capture
if (CFStringCompare ((__bridge_retained CFStringRef)mediaType, kUTTypeMovie, 0)
    == kCFCompareEqualTo) {

    NSString *movieFile = [[info objectForKey:
                            UIImagePickerControllerMediaURL] path];
    NSURL *movieURL = [NSURL fileURLWithPath:movieFile];

    NSLog(@"Movie File %@",movieURL);

    [self dismissViewControllerAnimated:YES completion:nil];
}
}

1 Answer 1

1

I don't know about the location it was taken but you can use File Attribute Keys to get the NSFileCreationDate using attributesOfItemAtPath:error:. There is a convenience method on NSDictionary fileCreationDate

NSError *error;
NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:movieFile error:&error];
if (!attributes) {
    // Use the error
}
NSDate *createdDate = [attributes fileCreationDate];

If you want to access the meta-data on the MOV file you can have a look at the EXIF data, I don't know if there is a iOS library for this though.

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you very much. You should edit the last line to be NSDate *createdDate = [attributes objectForKey:NSFileCreationDate]; instead. It returned the whole date instead of just part.
As per the docs fileCreationDate is the same as [attributes objectForKey:NSFileCreationDate], are you saying this is not the case?!
Nope I miss read my console. You are completely right. My apologies.
Ah no problem! Just wanted to check. Hope this is what you're looking for too :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.