Note that there are some explanatory texts on larger screens.

plurals
  1. POCheck ALAssetsLibrary empty or not
    primarykey
    data
    text
    <p>I am using ALAssetsLibrary and app getting crashed when it is empty.How do i check whether it is empty or not?.</p> <pre><code> -(void)getLastImageName1 { // if (val &lt; 10) { // NSLog(@"getLastImageName1\n"); ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; // Enumerate just the photos and videos group by using ALAssetsGroupSavedPhotos. last =1; [library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) { // Within the group enumeration block, filter to enumerate just photos. [group setAssetsFilter:[ALAssetsFilter allPhotos]]; if (last == 1) { // NSLog(@"last\n"); last++; // Chooses the photo at the last index [group enumerateAssetsAtIndexes:[NSIndexSet indexSetWithIndex:[group numberOfAssets]-1] options:0 usingBlock:^(ALAsset *alAsset, NSUInteger index, BOOL *innerStop) { // The end of the enumeration is signaled by asset == nil. if (alAsset) { NSString *lastImgNew = alAsset.defaultRepresentation.filename; // NSLog(@"current img name %@\n",lastImgNew); NSString *plistPath1 = [DOCUMENT_DIR_PATH stringByAppendingPathComponent:@"previouslastimagename.plist"]; NSArray *lastImg = [NSArray arrayWithContentsOfFile:plistPath1]; // NSLog(@"get pre lastimg %@\n",lastImg); // NSArray *lastImg = [[DBModel database]getPreviousName]; // NSLog(@"get lastImg %@\n",lastImg); if ([lastImg count] != 0) { // NSLog(@"count\n"); if ([[lastImg objectAtIndex:0] isEqualToString:lastImgNew]) { // NSLog(@"img eql\n"); // UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"" message:@"equal" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; // [alert show]; [self hideImage]; // } } else { // UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"" message:[NSString stringWithFormat:@"pre %@ current %@",[lastImg objectAtIndex:0],lastImgNew] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; // [alert show]; // NSLog(@"img not eql\n"); [self performSelectorOnMainThread:@selector(displayAlert) withObject:nil waitUntilDone:YES]; } } } }]; } } failureBlock: ^(NSError *error) { // Typically you should handle an error more gracefully than this. // NSLog(@"No groups"); }]; </code></pre> <p>The line which after last++ variable.I am checking lastimage with newscreenshot image to not allow user to use app after taking screenshot</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload