Title: What array is causing 'NSRangeException' exception?
Tags: ios;arrays;debugging;exception
Question: This is a debugging question.
I have been running into this exception quite a lot lately:
Terminating app due to uncaught exception 'NSRangeException', reason:
'*** -[__NSArrayI objectAtIndex:]: index 6 beyond bounds [0 .. 3]'
I get what is causing the exception but I am more wondering if there is any way to know what array is involved exactly ?
I am using about 30 arrays in my app and __NSArrayI doesn't really give me any clue about the array that is returning this exception.
Thanks in advance everyone :)
Comment: under the breakpoints tab on the panel on the left, add an exception breakpoint for all exceptions and then make it crash again and it should show you where

Comment: Really nice. Worked well. Thanks a lot!


Here is another answer: depends how you call the information stored in those arrays, if they all have the same number of elements, and in what order they're being called. if you provide your code it might be easier to give you an answer. If it's the only message the debugger is displaying than you might have to precede by elimination cuz it doesn't say much

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2015:00:09/07/15', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<ios><arrays><debugging><exception>', 'Title': "What array is causing 'NSRangeException' exception?", 'ViewCount': 43, 'id': 32430215, 'user_AboutMe': None, 'user_AccountId': 6315842.0, 'user_DisplayName': 'Aquaman', 'user_Reputation': 111.0, 'user_Views': 6.0, 'user_id': 4905839.0}}