0
votes

i need to categorise video on the basis of date and time on which it is created. I tried usin ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset) { CLLocation *location = [myasset valueForProperty:ALAssetPropertyLocation];

in (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

delegate but it reflects current date and time.

1

1 Answers

0
votes

In your code sample above, looks like you're trying to get your latitude and longitude. :-)

To get the date and time of an ALAsset, simply do something like this;

    NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"dd-MM-yyyy 'at' HH:mm"];
    NSDate * dateFileCreated = [theAsset valueForProperty: @"ALAssetPropertyDate"];

    NSLog( @"date for this file is %@ %@", [[[theAsset defaultRepresentation] url] absoluteString], [dateFormatter stringFromDate: dateFileCreated] );
    [dateFormatter release];

I put a date formatter in there so you can see the date in your console log, but in release code you probably do NOT want to allocate and release a formatter while enumerating ALAssets.

Hope this information helps you out!