NSRangeException is raised when you access a range outside its normal bounds. Range exceptions most commonly occur when looping an array starting at index 1 rather than starting at index 0 as intended.
Questions tagged [nsrangeexception]
130 questions
                    
                    38
                    
            votes
                
                0 answers
            
        NSRangeException Out of Bounds error
I am setting the attributed text of a label, and I am getting this strange error: Terminating app due to uncaught exception 'NSRangeException', reason: 'NSMutableRLEArray replaceObjectsInRange:withObject:length:: Out of bounds'. I have never seen…
         
    
    
        Chandler De Angelis
        
- 2,646
- 6
- 32
- 45
                    18
                    
            votes
                
                1 answer
            
        NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds
I try to assign attributes to 3 last chars of newClock string, which is @"3:33:23".
However I  get an error when construct NSRange:
NSMutableAttributedString *mas = [[NSMutableAttributedString alloc]initWithString:newClock];
[mas…
         
    
    
        Shmidt
        
- 16,436
- 18
- 88
- 136
                    12
                    
            votes
                
                3 answers
            
        IndexOfObject return 2147483647
I have an array with 10 items. When I call "IndexOfObject" for the elements number 9 and the element number 10 Xcode return an exception: "NSRangeException" 
reason: '_[_NSCFArray objectAtIndex:] index:2147483647 beyond
  bounds(10)'.
From a…
         
    
    
        Ortensia C.
        
- 4,666
- 11
- 43
- 70
                    8
                    
            votes
                
                2 answers
            
        Finding out source of nsrangeexception
I have an NSRangeException error that does not occur all the time(especially when I am debugging). It comes up randomly, and I am unable to figure out where it is coming from. I have lots of array manipulation, so its difficult to eliminate it that…
         
    
    
        user542584
        
- 2,651
- 2
- 25
- 29
                    6
                    
            votes
                
                3 answers
            
        google analytics last screen before crash for ios
My application crashes with very poor info. Is there a way that I could find the last screen name, in google analytics, when application crashes? I am tracking every screen in my application. This way I could know in what controller the bug exists.…
         
    
    
        Lukas
        
- 2,515
- 4
- 28
- 37
                    5
                    
            votes
                
                4 answers
            
        Mixing static and dynamic UITableViewController content causes NSRangeException
I have been searching all over for this error and did find some few posts with a similar behavior but no solution that solves the problem.
I have a UITableViewController (declared as Static in SB) which has to Sections: Section 0 (Recipe) is static…
         
    
    
        DonBaron
        
- 1,354
- 1
- 10
- 18
                    5
                    
            votes
                
                3 answers
            
        NSRangeException following Core Data migration
After adding a new Core Data model version to my app, I performed a lightweight migration, apparently successfully. The migrated file loaded fine, but upon the first attempt to access an attribute via a particular relationship, the app crashes with…
         
    
    
        David Ravetti
        
- 2,030
- 1
- 17
- 22
                    4
                    
            votes
                
                4 answers
            
        Index '5' beyond bounds of empty array crash
I'm building an RSS-Reader and put a refreshbutton on the right corner of the navigation bar. It works fine and I get no crashes. But if if I press the refresh button during scrolling the app crashes. And I have no idea where the problem is. I…
         
    
    
        AmiiQo
        
- 353
- 1
- 7
- 17
                    4
                    
            votes
                
                2 answers
            
        NSRangeException, reason: 'Attempted to scroll the table view to an out-of-bounds...'
Got a UITableView that I'm populating with ChatMessage objects, that I keep in a Dictionary that is grouped by date sent like so var groupedMessages = [Date : [ChatMessage]]()
I'm also keeping keys in var keys = [Date]()
Setting sections and…
         
    
    
        Bernhard Engl
        
- 243
- 1
- 2
- 12
                    4
                    
            votes
                
                2 answers
            
        Understanding arrayWithCapacity: method on NSMutableArray
I'm having a hard time trying to understand a method in the Objective-C's NSMutableArray class. I created an array using the arrayWithCapacity: static method of this class, just like this:
NSMutableArray * myArray = [NSMutableArray…
         
    
    
        Daniel Bastos
        
- 143
- 2
- 10
                    4
                    
            votes
                
                1 answer
            
        UIScrollView setContentSize crashes with uncaught NSRangeException
Call to setContentSize crashes the application after some of the UIScrollView's contents have been removed.
int toolbarHeight = [[[self navigationController] toolbar] frame].size.height;
int navbarHeight = [[[self navigationController]…
         
    
    
        Gerstmann
        
- 5,368
- 6
- 37
- 57
                    3
                    
            votes
                
                1 answer
            
        UIWebView NSRangeException
I try to load into UIWebView of a UIViewController a 360 panorama which is in html format and built in krpano. When the panorama opens all work properly. Although after some time, I get much of these errors to console :
Feb 28 14:02:54…
         
    
    
        hoya21
        
- 893
- 7
- 24
                    3
                    
            votes
                
                1 answer
            
        Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 5 beyond bounds [0 .. 4]' in IOS
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    data_web *current_data ;
    current_data = [[structured_question data_webs] objectAtIndex:indexPath.row];
   …
         
    
    
        Aragon
        
- 59
- 2
- 8
                    3
                    
            votes
                
                1 answer
            
        Modifying NSFetchRequest generating NSRangeException index 0 beyond bounds for empty array
In my latest iOS App Update, I'm seeing a significant increase in DB related crashes.  I'm seeing crashes from almost every line of code that runs a fetch on the DB.
Exception:
NSRangeException
* -[__NSArrayM objectAtIndex:]: index 0 beyond bounds…
         
    
    
        FishStix
        
- 4,994
- 9
- 38
- 53
                    2
                    
            votes
                
                3 answers
            
        NSRangeException using -[ALAssetsGroup enumerateAssetsUsingBlock:]
I am currently using some pretty standard code to enumerate assets in a group. Except now I have a new error
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSOrderedSet…
         
    
    
        The Lazy Coder
        
- 11,560
- 4
- 51
- 69