Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7079279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:39:09+00:00 2026-05-28T06:39:09+00:00

EDIT: i replaced arc4random() to arc4random_uniform() for fix I’m using test flight to monitor

  • 0

EDIT: i replaced arc4random() to arc4random_uniform() for fix

I’m using test flight to monitor crashes.
been fixing bugs, however i encounter this bug, i’m not sure why the index is so big.

 -[__NSArrayM objectAtIndex:]: index 4294967295 beyond bounds for empty array

it is likely that this is where the bug is

for (NSUInteger i = 0; i < count; ++i) {
        // Select a random element between i and end of array to swap with.
        int nElements = count - i;
        int n = (arc4random() % nElements) + i;
        [randomName exchangeObjectAtIndex:i withObjectAtIndex:n];
        [randomImgName exchangeObjectAtIndex:i withObjectAtIndex:n];
        [randomID exchangeObjectAtIndex:i withObjectAtIndex:n];
    }

which caused crashes here

//Frog Name Caption
    NSString * tempCaption = [defaultFrogImageCaption objectAtIndex:[defaultFrogImageCaption count]-1];
    self.dFrogID = [defaultFrogID objectAtIndex:[defaultFrogID count]-1];

i believe this is the bug, but i do not know how to solve the error.

appreciated all the comment and help

-(void)defaultFrogSetup
{
self.imageArray = [[NSMutableArray alloc] initWithObjects:
                       [UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"defaultFrog/d7.jpg"]],
                       [UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"defaultFrog/d9.jpg"]],
                       [UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"defaultFrog/d11.jpg"]],
                       [UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"defaultFrog/d27.jpg"]],
                       [UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"defaultFrog/d6.jpg"]],                        
                       nil];

    //self.defaultFrogID = [[NSMutableArray alloc] initWithObjects:@"6",@"8",@"10",@"26",@"5",nil];
    self.defaultFrogID = [[NSMutableArray alloc] initWithObjects:@"6",@"8",@"10",@"24",@"5",nil];
    self.defaultFrogImageCaption = [[NSMutableArray alloc] initWithObjects:@"Verreaux's Tree Frog",@"Green Tree Frog",@"Red-Eyed Tree Frog",@"Crucifix Frog",@"Eastern Dwarf Tree Frog",nil];    

    NSUInteger count = [self.defaultFrogID count];
    //NSLog(@"Count %i",[self.defaultFrogID count]);
    NSMutableArray *randomImgName = self.imageArray;
    NSMutableArray *randomID = self.defaultFrogID;
    NSMutableArray *randomName = self.defaultFrogImageCaption;

    //likely bug here
    for (NSUInteger i = 0; i < count; ++i) {
        // Select a random element between i and end of array to swap with.
        int nElements = count - i;
        int n = (arc4random() % nElements) + i;
        [randomName exchangeObjectAtIndex:i withObjectAtIndex:n];
        [randomImgName exchangeObjectAtIndex:i withObjectAtIndex:n];
        [randomID exchangeObjectAtIndex:i withObjectAtIndex:n];
    }
    self.imageArray = randomImgName;
    self.defaultFrogID=randomID;
    self.defaultFrogImageCaption=randomName;

    //NSLog(@"default filename %@",self.defaultFrogImageCaption);
    //NSLog(@"default frog ID %@",self.defaultFrogID);

    self.imageViewTop.alpha = 1.0;
    self.imageViewBottom.alpha = 0.0;
    self.imageViewBottom = [[UIImageView alloc] initWithFrame:CGRectMake(0,44,320,367)];
    self.imageViewTop = [[UIImageView alloc] initWithFrame:CGRectMake(0,44,320,367)];
    [self.view addSubview:imageViewTop];
    [self.view addSubview:imageViewBottom];
    self.buttonCaption = [UIButton buttonWithType:UIButtonTypeCustom];
    //default placement
    self.buttonCaption.frame = CGRectMake(245, 367, 70, 44);
    //[buttonCaption setTitle:@"\u00A9"  forState:UIControlStateNormal];
    [self.buttonCaption addTarget:self action:@selector(buttonCheck) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.buttonCaption];
    [self defaultFrogAnimation:buttonCaption.frame.size.width];    

}

-(void)defaultFrogAnimation:(float)previousWidth {




    defaultFrog = 1;
    foundFrog = 0;

    //picture loop
    imageViewTop.image = imageViewBottom.image;
    imageViewBottom.image = [imageArray objectAtIndex:[imageArray count] - 1]; 
    [imageArray insertObject:imageViewBottom.image atIndex:0];
    [imageArray removeLastObject];
    imageViewTop.alpha = 1.0;
    imageViewBottom.alpha = 0.0;

    //Frog Name Caption
    NSString * tempCaption = [defaultFrogImageCaption objectAtIndex:[defaultFrogImageCaption count]-1];
    self.dFrogID = [defaultFrogID objectAtIndex:[defaultFrogID count]-1];

    // make the buttons content appear in the top-left
    [buttonCaption setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter];
    [buttonCaption setContentVerticalAlignment: UIControlContentVerticalAlignmentCenter ];    

    [defaultFrogImageCaption insertObject:tempCaption atIndex:0];
    [defaultFrogImageCaption removeLastObject];
    [defaultFrogID insertObject:dFrogID atIndex:0];
    [defaultFrogID removeLastObject];

    //button setting

    [buttonCaption.titleLabel setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
    [buttonCaption.titleLabel setFont:[UIFont systemFontOfSize:17]];
    [buttonCaption setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

    [[buttonCaption layer] setCornerRadius:5.0f];
    [[buttonCaption layer] setMasksToBounds:YES];
    [[buttonCaption layer] setBackgroundColor:[[UIColor colorWithRed:255 green:255 blue:255 alpha:1] CGColor]];   
    [buttonCaption.titleLabel setFrame:CGRectMake(0,9, 25, 25)];
    stringsize = [tempCaption sizeWithFont:[UIFont systemFontOfSize:19]];  
    CGFloat diff = stringsize.width - previousWidth;
    //NSLog(@"diff %f",diff);

    [UIView animateWithDuration:3

                     animations:^{ 
                         imageViewTop.alpha = 0.0;
                         imageViewBottom.alpha = 1.0;
                     } 
                     completion:^(BOOL  completed){
                         if (completed)        
                             [self defaultFrogAnimation:stringsize.width];                  
                     }                      

     ];    

    [UIView animateWithDuration:0.1 delay:0 options:0       
                     animations:^{                          
                         [buttonCaption setTitle:tempCaption   forState:UIControlStateNormal];

                         NSLog(@"frog Name %@",tempCaption );
                         NSLog(@"frog ID %@",dFrogID);
                     } 
                     completion:^(BOOL  completed)
     {
     }];     

    [UIView animateWithDuration:0.3 delay:0 options:0       
                     animations:^{ 
                         [buttonCaption setFrame:CGRectMake(buttonCaption.frame.origin.x-diff, 
                                                            buttonCaption.frame.origin.y, 
                                                            buttonCaption.frame.size.width + diff, 
                                                            buttonCaption.frame.size.height)];                         
                     } 
                     completion:^(BOOL  completed){
                     }];  
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:39:10+00:00Added an answer on May 28, 2026 at 6:39 am

    The size of the array is zero. The large number is actually -1 expressed as an unsigned integer. When you evaluate [array count]-1, since the array size is zero, it attempts to access the object at index -1. I suspect that the array defaultFrogId or defaultFrogIdCaption is empty because you didn’t specify retain or something when you declared it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT SO I figured out a fix. I replaced the while statement with an
EDIT: woah ... somehow i replaced this question with another one i was asking,
FINAL EDIT (RESOLVED) I just replaced if(empty($num1)) with if(!isset($num1)) and now the conditional Required!
Edit 3: I replaced __file__ with sys.argv[0] , when I need to know the
I'm using Microsofts Expression Web 5 to edit my HTML documents. I have noticed
EDIT: As recommended by svick I replaced the custom IPropagatorBlock with a simple TransformBlock,
EDIT: Following Mike Seymour's comment, I replaced operator std::string () const; with operator char
When I copied _form.haml partial to _edit_form.haml partial and replaced _form, with _edit_form in
We have an application that allows users to add/edit/replace/delete content (text, images, swfs, mp3s,
I need to edit or completely replace outline data (bezier curves) of OpenType fonts.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.