我正在构建一个应用程序,让用户从他们的库中拍照来做事情。我使用的是X代码,而且我的代码是在&f; finishLaunchingWithOptions'但不断获得一个未声明的标识符'错误。怎么办?
ALAssetsLibraryGroupsEnumerationResultsBlock assetGroupEnumerator =
^(ALAssetsGroup *assetGroup, BOOL *stop) {
if (assetGroup != nil) {
// do somthing
}
};
ALAssetsLibraryAccessFailureBlock assetFailureBlock = ^(NSError *error) {
LogError(@"Error enumerating photos: %@",[error description]);
};
NSUInteger groupTypes = ALAssetsGroupAll;
[library enumerateGroupsWithTypes:groupTypes usingBlock:assetGroupEnumerator failureBlock:assetFailureBlock];
答案 0 :(得分:0)
答案太迟了但你需要定义库
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
或更好地使用类方法,如果您要重用该库以进行更多查询
+ (ALAssetsLibrary *)defaultAssetsLibrary
{
static dispatch_once_t pred = 0;
static ALAssetsLibrary *library = nil;
dispatch_once(&pred, ^{
library = [[ALAssetsLibrary alloc] init];
});
return library;
}