LoginSignup
5
5

More than 5 years have passed since last update.

PhotoAlbumにアクセス出来るか確認する

Posted at

ALAssetsLibraryフレームワークから認可状態を取得できる(iOS 6.0以降)。

#import <AssetsLibrary/AssetsLibrary.h>

// 認可状態の取得
ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];

if (status == ALAuthorizationStatusAuthorized) {
  // 認可されている
} else {
  // 認可されていない
}

ALAssetsLibrary:authorizationStatusALAuthorizationStatusを返すので、状態に応じてハンドリングをする。
iOS 7.1 SDKでのALAuthorizationStatusの値は次のようになっている。

typedef NS_ENUM(NSInteger, ALAuthorizationStatus) {
    ALAuthorizationStatusNotDetermined = 0, // アプリで認可 / 拒否を行ったことがない
    ALAuthorizationStatusRestricted,        // ペアレンタル・コントロールやプロファイル定義によって制限されている。
    ALAuthorizationStatusDenied,            // 拒否。
    ALAuthorizationStatusAuthorized         // 認可済み。
} __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_6_0);

参考。

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5