How do I convert AVMetadataItem value to NSDate or NSString?

163 views Asked by At

I am trying to get the date a video was taken and populate a TextView with it in Xcode. I have chosen the video and then gotten the date from the AVMetadataItem creationDate. I can print it out as a NSLog but I want to convert it into a String or NSData. Here is my code in objective-c

in .h

@property(nonatomic, readonly, nullable) AVMetadataItem *creationDate;

and in .m

NSURL * movieURL = [info valueForKey:UIImagePickerControllerMediaURL] ;
       AVURLAsset *anAsset = [[AVURLAsset alloc] initWithURL:movieURL options:nil];
        NSLog(@"creationDate:%@",anAsset.creationDate.value);

in the log I get creationDate:Tue Jan 26 09:44:39 2021 which is the date I took the video. My problem is now converting it to a usable form.

When I try

NSString = anAsset.creationDate.value;

I get a warning

Initializing 'NSString *_strong' with an expression of incompatible type 'id<NSObject,NSCopying> _Nullable'

I basically get this same warning no matter what I try.

Can someone help me get this working?

0

There are 0 answers