Questions tagged [nsrangeexception]

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.

130 questions
0
votes
1 answer

NSRangeException when trying to display table view controller

I'm trying to display a grouped table view containing three cells, each with a UISwitch. I thought I had everything set up, but when I segue to the view controller from my app's main screen, an NSRangeException is thrown somewhere and my app…
Peter W.
  • 2,323
  • 4
  • 22
  • 42
0
votes
3 answers

Why is this '*** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array'

Why I am getting a MSRangeException with this code: NSArray *patientenVornamen = [NSArray arrayWithObjects:@"Michael", @"Thomas", @"Martin", nil]; NSArray *patientenNachnamen = [NSArray arrayWithObjects:@"Miller", @"Townsend", @"Mullins",…
mrd
  • 4,561
  • 10
  • 54
  • 92
0
votes
1 answer

UIPickerView with multiple components

I'm new to Xcode. I now want to implement a UIPickerView with 2 columns in my app. The first column is number(e.g. 1 - 5) and the second column is unit(e.g. day , week).For example 1 day, 2 days, 3 weeks. I tried the following code: -…
user3195152
  • 23
  • 1
  • 5
0
votes
3 answers

Two TextFields in a View Controller set as the delegate, causing the app to crash with NSRange, range or index out of bounds

I have a view controller that annoyingly keeps crashing. The textfield has 3 textFields (name, item, title) and everything was working well before I tried to introduce the UITextFieldDelegate method. - (BOOL)textFieldShouldReturn:(UITextField…
0
votes
3 answers

NSRangeException in UITableView

This is my code within tableView:cellForRowAtIndexPath: method, static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc]…
Vishal
  • 101
  • 1
  • 12
0
votes
0 answers

Resolving Beyond Bounds Error in iOS

An app I'm working is crashing due to an out of bounds error - I should be able to figure out why however the output console does not show which array in the code is causing the crash - does anyone have any ideas on how I can find out. …
Sae Us
  • 277
  • 1
  • 6
  • 21
0
votes
1 answer

NSRangeException while using substringWithRange:NSMakeRange

I'm having an odd error I don't understand. I've looked at other questions, and I see that NSMakeRange is anchor, distance to traverse. This single statement causes a NSRangeException, out of bounds error though: if([myCompare…
0
votes
1 answer

NSRangeException even the range is correct in NSString Replace

I have written a code to replace delete the substring in NSString...my logic was to use 'rangeofString' to find the position of each substring characters and then using 'ReplaceOccurance' to replace the substring characters by space and later trimm…
Raon
  • 1,266
  • 3
  • 12
  • 25
0
votes
2 answers

Obj-C/Cocoa How to check if [string characterAtIndex:i] is returning an NSRangeException?

I have a for loop. for (i=0; i <= stringLength; i++) { unichar currentCharacter = [string characterAtIndex:i]; ...} I understand from the documentation that characterAtIndex: will usually return a value of the type 'unichar' but if our index is…
Oliver
  • 403
  • 3
  • 14
0
votes
4 answers

I am getting a "Terminating due to uncaught exception 'NSRangeException'" message when trying to run my app

Main.m int main(int argc, char *argv[]) { @autoreleasepool { return UIApplicationMain (argc, argv, nil, NSStringFromClass ([AppDelegate class])); } } The debugger says the…
0
votes
1 answer

App crashes with 'NSRangeException' when library is empty

I am using this code to get the latest photo from the cameraRoll: - (void) getTheLatestPhoto{ ALAssetsLibrary *cameraRoll = [[ALAssetsLibrary alloc] init]; [cameraRoll enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos…
0
votes
1 answer

NSRangeException on textField/textView becomeFirstResponder

I have 2 textFields and 1 textView on a view. Only one of the textFields has the vc as a delegate. Whenever any of the 3 become firstResponder (either programmatically, or by being tapped), the app crashes. The error is: *** Terminating app due to…
Shane Rayner
  • 672
  • 6
  • 8
0
votes
1 answer

Xcode 4 NSRangeException Error after split string

I'm trying to split a string and separate it into variable but am getting the following error: * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayM objectAtIndex:]: index 2 beyond bounds [0 .. …
NCoder
  • 325
  • 3
  • 10
  • 25
0
votes
2 answers

NSRangeException randomly crash app

My app crash ramdomly in _storeArray. In viewDidLoad, have a method [self loadUrl] that parse a xml file then add an dictionary [_storeArray addObject:dictionary]; The crash happens when somehow the carousel reusingView call first then [self…
Marckaraujo
  • 7,422
  • 11
  • 59
  • 97
0
votes
1 answer

Terminating app due to uncaught exception 'NSRangeException'. [__NSArrayM objectAtIndex:]: index 33 beyond bounds [0 .. 32]'

I have this ImportViewController.m i am extracting and loading names from xml from server. total number of elements is 33. - (void)viewDidLoad { [super viewDidLoad]; self.title = @"IMPORT"; NSLog(@"User id = %@",currentUserId); …
1 2 3
8 9