2015-10-16 56 views
-1

我試圖檢查,但我得到了以下錯誤:ALAuth檢查工作不

Error 1: initializer element is not compile-time constant 
Error 2: Excepted identifier or '(' 

下面的代碼:

#import <UIKit/UIKit.h> 
#import <AssetsLibrary/AssetsLibrary.h> 

//(Error 1) ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus]; 

//(Error 2) if (status != ALAuthorizationStatusAuthorized) { 
    //show alert for asking the user to give permission 

} 

這些代碼是在我的.m文件,我該如何解決這個問題(請附上代碼)?

+1

你不能在任何地方粘出代碼。提供一些背景。 – rmaddy

+0

@rmaddy我擔心這是上下文。他只是將代碼粘在一邊。那就是問題所在。 – matt

+0

「請包含代碼」No.堆棧溢出不是「請發送Codez」網站。如果你有一個合理的編程問題,問問題。 – matt

回答

0

糟糕,我犯了一個小錯誤。我忘了添加viewdidload

#import <UIKit/UIKit.h> 
#import "BaseViewController.h" 
#import <AssetsLibrary/AssetsLibrary.h> 

@interface ViewController14() 

@end 

@implementation ViewController14 
- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus]; 

    if (status != ALAuthorizationStatusAuthorized) { 
     //show alert for asking the user to give permission 

    } 
} 

@end