IOS 5 的 ALAssetsGroup 问题
我的代码在 OS 4.3 上运行 但随着 5 我收到有关 ALAssetsGroup 的警告 对于 ALAssetsGroup 我没有得到任何方法,所以我得到了未找到枚举的实例 查看代码
void (^assetEnumerator)(ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop)
{
if(result != nil)
{
[assets addObject:result];
}
};
// Create instance of the Assets Library.
void (^assetGroupEnumerator)( ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop) {
if(group != nil)
{
[group enumerateAssetsUsingBlock:assetEnumerator];
}
};
assets = [[NSMutableArray alloc] init];
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAlbum
usingBlock:assetGroupEnumerator
failureBlock: ^(NSError *error) {
NSLog(@"failureBlock:%@",error);
}];
任何帮助将不胜感激 谢谢
My code was working on OS 4.3
but with 5 i am getting warnings regarding ALAssetsGroup
for the ALAssetsGroup i dont get any methods for it so i get instance not found for the enumerate
see code
void (^assetEnumerator)(ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop)
{
if(result != nil)
{
[assets addObject:result];
}
};
// Create instance of the Assets Library.
void (^assetGroupEnumerator)( ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop) {
if(group != nil)
{
[group enumerateAssetsUsingBlock:assetEnumerator];
}
};
assets = [[NSMutableArray alloc] init];
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAlbum
usingBlock:assetGroupEnumerator
failureBlock: ^(NSError *error) {
NSLog(@"failureBlock:%@",error);
}];
Any help will be appreciated
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从 iOS 5 开始,更多的 Assets-Library 方法是异步的,需要从主线程调用。
确保您在主队列上使用dispatch_async调用第二个块来枚举主线程中的组。
干杯,
亨德里克
as of iOS 5 more Assets-Library methods are asynchronous and want to be called from the main-thread.
Make sure you call your 2nd block enumerating the group from the main-thread using dispatch_async on the main-queue.
Cheers,
Hendrik