Yes, it is possible.
You have to use ALAssetsLibrary
to access your camera roll. Then you just enumerate through your photos and asks for location.
assetsLibrary = [[ALAssetsLibrary alloc] init];
groups = [NSMutableArray array];
[assetsLibrary enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop)
{
if (group == nil)
{
return;
}
[groups addObject:group];
} failureBlock:^(NSError *error)
{
// Possibly, Location Services are disabled for your application or system-wide. You should notify user to turn Location Services on. With Location Services disabled you can't access media library for security reasons.
}];
This will enumerate your assets groups. Next, you pick up a group and enumerate its assets.
ALAssetGroup *group = [groups objectAtIndex:0];
[group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop)
{
if (result == nil)
{
return;
}
// Trying to retreive location data from image
CLLocation *loc = [result valueForProperty:ALAssetPropertyLocation];
}];
Now your loc
variable contains location of the place where the photo was taken. You should check it against ALErrorInvalidProperty
before use, since some photos might lack this data.
You can specify ALAssetPropertyDate
to obtain the date and time of photo creation.