ALAssetsLibrary 无效或为空 [英] ALAssetsLibrary invalid or null

查看:33
本文介绍了ALAssetsLibrary 无效或为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误消息:无效尝试访问 当我尝试创建自定义图像选择器时,它已超过其拥有的 ALAssetsLibrary 的生命周期.

I get the following error message : invalid attempt to access <ALAssetPrivate: 0xa4a1ed0> past the lifetime of its owning ALAssetsLibrary when I try to create custom Image Picker.

我使用了这个 APPLE 示例来创建此应用程序.示例 Apple 应用程序运行良好.但是当我将该示例代码复制到我的应用程序时,它会收到上述错误消息.

I used this APPLE sample to create this app. The sample Apple app works perfectly. But when I copied that sample code to my app it get the above error message.

请有人帮助我为什么会出现此错误&ALAssetsGroup 变为空.

Please can someone help me why this error comes & ALAssetsGroup become null.

推荐答案

我找到了这个问题的答案.问题是我使用的 ALAssetsLibrary 通过 ARC 得到了空值.解决方案是,添加这个静态方法而不是 ALAssets 库..

I found the answer for this problem. The problem is my ALAssetsLibrary I used got null by ARC. The solution is, add this static method instead of ALAssets Library..

+ (ALAssetsLibrary *)defaultAssetsLibrary {
    static dispatch_once_t pred = 0;
    static ALAssetsLibrary *library = nil;
    dispatch_once(&pred, ^{
        library = [[ALAssetsLibrary alloc] init];
    });
    return library; 
}

来源

这篇关于ALAssetsLibrary 无效或为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆