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
1
vote
1 answer
NSRangeException in TableView with Sections [indexPath Row] goes out of range
Here is the error printed out to the console:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '***
-[__NSArrayI objectAtIndex:]: index 2 beyond bounds [0 .. 1]'
*** First throw call stack:
(0x27f0012 0x1a51e7e 0x27a5b44…

user1066524
- 373
- 2
- 11
- 24
1
vote
2 answers
Looping through an array, index error
I am creating a UIScrollView that scrolls sideways and has a number of buttons and labels (that go with the buttons) that I am adding programmatically.
I have 44 buttons and labels, so I want to create them through an array.
This is how I am…

tyler53
- 429
- 1
- 5
- 16
1
vote
0 answers
Dismissing imagePickerController from UITabBarController and switching tabs causes NSRangeException
I have a tab bar controller, where one of the tabs just brings up the camera. Once the user is dont taking pictures, I want them to to go to another tab that lists the photos they've taken so far (that are saved in the app's directory).
This is how…

Shinigami
- 2,123
- 23
- 40
1
vote
1 answer
NSMutableArray remove objectAtIndex NSRangeException IOS
I get NSRangeException error when I try to removeObjectAt:0 . I don't know how that is even possible.
-(void)removePoints:(ccTime *)tm
{
NSLog(@"naughty %@",_naughtytoucharray);
if ([_naughtytoucharray count]>0)
{
…

Mord Fustang
- 1,523
- 4
- 40
- 71
1
vote
1 answer
'NSRangeException' while reading data from a file
I am trying to save data when the home button is pressed.
Here is my relevant code.
- (NSString *) saveFilePath
{
NSArray *path =
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
return [[path…

Ali Sufyan
- 2,038
- 3
- 17
- 27
1
vote
2 answers
'NSRangeException', reason: '* -[__NSArrayM objectAtIndex:]: index 2 beyond bounds [0 .. 1]'
I'm trying to delete some items but i'm receiving this NSException:
'NSRangeException', reason: '* -[__NSArrayM objectAtIndex:]: index 2 beyond bounds [0 .. 1]'
Here is my code:
-(void)deletePressed:(id)sender {
if (data.count > 0) {
NSString…
user1766496
0
votes
0 answers
App crashes when tap on UITextfield after chaning the app language
I just add the text field as a search bar, didn't set any delegate or other stuff. I change the App language and after reloading the view just tap on the text field app gets crashed.
Xcode console shows.
invalid mode 'kCFRunLoopCommonModes' provided…

syed aurangzaib
- 11
- 3
0
votes
0 answers
Index 16 out of bounds; string length 0 in swift
i try to decode some string, which encoded within AES. When the input is string without encode. My app crash. Log:
Terminating app due to uncaught exception 'NSRangeException', reason: '** -[__NSCFConstantString substringFromIndex:]: Index 16 out of…

minhtam23
- 49
- 1
- 8
0
votes
1 answer
NSMutableOrderedSet lastObject NSRangeException crash
On average, I have a NSMutableOrderedSet where a new custom object is added every second. Every time a new data arrives, a reference to the lastObject is updated. Also at the end of method, if NSMutableOrderedSet count is bigger than 300 first…

Batuhan Altun
- 69
- 8
0
votes
2 answers
Why does this conditional cause an error?
I have a method that contains a few conditionals. The first conditional works fine and does not cause any problems. However, the second one causes the app to crash.
- (void)didReceiveGaiaGattResponse:(CSRGaiaGattCommand *)command
{
…

VK1
- 1,676
- 4
- 28
- 51
0
votes
0 answers
Swift 3 range exception?
let x = self.tableProduct.count
self.tableProduct = products
self.tableView.beginUpdates()
var insertedIndexPaths = [IndexPath]()
for i in x..

e.k
- 1,333
- 1
- 17
- 36
0
votes
1 answer
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArray0 objectAtIndex:]: index 0 beyond bounds for empty NSArray'
I am fetching the labels, text and image through API. When API has data , it shows without error. But when the API is nil, it throws error as:
Terminating app due to uncaught exception 'NSRangeException', reason:
'*** -[__NSArray0…

Tamannah
- 127
- 2
- 13
0
votes
1 answer
Swift sometimes give this AppDelegate Error when try to find user location "Terminating app due to uncaught exception 'NSRangeException'.."
Swift sometimes give this AppDelegate Error when try to find user location
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArray0 objectAtIndex:]: index 0 beyond bounds for empty NSArray'
*** First throw call…
user7904906
0
votes
2 answers
navigationController?.isNavigationBarHidden = true causes NSRangeException in Swift. How can I prevent it?
I have a UITabController with two UIViewControllers embedded in it.
Both of them have the following code in viewWillAppear:
override func viewWillAppear(_ animated: Bool){
super.viewWillAppear(animated)
…

user3766930
- 5,629
- 10
- 51
- 104
0
votes
0 answers
Uncaught Exception When Resizing Image in OpenCV
I was trying to resize an image in a function using opencv that is called within a continous loop for socket transmissions and I obtained this error
2017-04-10 15:46:47.200 python[1541:16193] *** Terminating app due to uncaught exception…

Dendi Suhubdy
- 2,877
- 3
- 19
- 20