はい、可能です。
カメラロールにアクセスするには、ALAssetsLibrary
を使用する必要があります。次に、写真を列挙し場所を尋ねるだけです。
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.
}];
これで資産グループが列挙されます。次に、グループを選択し、そのアセットを列挙します。
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];
}];
ここで、loc
変数には、写真を撮影した場所の場所が含まれています。一部の写真ではこのデータが不足している可能性があるため、使用前にALErrorInvalidProperty
と確認してください。
ALAssetPropertyDate
を指定すると、写真の作成日時を取得できます。