大佬教程收集整理的这篇文章主要介绍了ios – ALAssetPrivate超过其拥有的ALAssetsLibrary的生命周期,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
ALAssetsLibrary *al = [ViewController defaultAssetsLibrary]; ALAssetsGroupEnumerationResultsBlock groupEnumerAtion = ^(ALAsset *result,NSUInteger index,BOOL *stop){ if (result!=NULL) { if ([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypePhoto]) { [imagesGotFromUserLibrary addObject:result]; } } }; ALAssetsLibraryGroupsEnumerationResultsBlock libraryGroupsEnumeration = ^(ALAssetsGrouP* group,BOOL* stop){ [group setAssetsFilter:[ALAssetsFilter allPhotos]]; if (group!=nil) { [group enumerateAssetsUsingBlock:groupEnumerAtion]; } else { dispatch_async(dispatch_get_global_queue(0,0),^{ GalleryCollectionViewController *otherController = [[GalleryCollectionViewController alloc] init]; [otherController receiveImagesWithMutableArray:imagesGotFromUserLibrary]; }); } }; al = [[ALAssetsLibrary alloc] init]; [al enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:libraryGroupsEnumeration failureBlock:^(NSError *error){ NSLog(@"ERROR: %@",error); }];
这是在viewDidLoad然后:
+ (ALAssetsLibrary *)defaultAssetsLibrary { static dispatch_once_t pred = 0; static ALAssetsLibrary *library = nil; dispatch_once(&pred,^{ library = [[ALAssetsLibrary alloc] init]; }); return library; }
这段代码是将数组发送到另一个控制器,将控制器设置为UICollectionView.问题是,我收到错误“无效尝试访问其拥有的ALAssetsLibrary的生命周期”,如果我尝试使用NSLog我的数组,结果就像“ALAsset – Type:UnkNown”,URL:(null)“.
我抬头看了互联网,找到了一个解决方案.我应该添加这行代码,但它不起作用.代码是:
+ (ALAssetsLibrary *)defaultAssetsLibrary { static dispatch_once_t pred = 0; static ALAssetsLibrary *library = nil; dispatch_once(&pred,^{ library = [[ALAssetsLibrary alloc] init]; }); return library; }
以上是大佬教程为你收集整理的ios – ALAssetPrivate超过其拥有的ALAssetsLibrary的生命周期全部内容,希望文章能够帮你解决ios – ALAssetPrivate超过其拥有的ALAssetsLibrary的生命周期所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。