ALAssetsLibrary invalid or null

☆樱花仙子☆ 提交于 2019-12-24 11:37:57

问题


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.

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.

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


回答1:


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; 
}

Source



来源:https://stackoverflow.com/questions/22662464/alassetslibrary-invalid-or-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!