iOS frequently opens album crashes: alassetslibrary Error-"Too many contexts. No space in Contextlist. "
http://stackoverflow.com/questions/13480611/ Has-anyone-experienced-crashes-when-using-alassetslibrary-in-a-background-thread
Reason:
Because of frequent calls
[[alassetslibrary alloc] init]
Even if your album is closed, but if you call this phrase frequently, in the ARC mode, it is estimated that iOS is not emptying memory in time,
will lead to "Too many contexts. No space in Contextlist. "
Therefore, the workaround is to use a singleton call.
+ (Alassetslibrary *) defaultassetslibrary{ static dispatch_once_t pred = 0; static alassetslibrary *library = nil; Dispatch_once (&pred, ^{ library = [[Alassetslibrary alloc] init]; }); return library;}
Or I used the Dbcamera library, which has provided a way to directly use the line.
Alassetslibrary *sharedlibrary = [[Dblibrarymanager sharedinstance] defaultassetslibrary]; [Sharedlibrary enumerategroupswithtypes:alassetsgroupall usingblock:^ (alassetsgroup *group, BOOL *stop) { if (group) { NSString *namestr = [group valueforproperty:alassetsgrouppropertyname]; } failureblock:^ (Nserror *error) { NSLog (@ "Failureblock"); }];
It's not so easy to crash after the test.
iOS frequently opens album crashes: alassetslibrary Error-"Too many contexts. No space in Contextlist. "