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
2
votes
1 answer

NSAttributedString: check if NSRange is valid

Given a NSRange and a NSAttributedString, what's the best way to verify that the range is valid, and won't exceed the bounds of the attributed string? I am trying to do this: [mutableAttributedString enumerateAttribute:NSFontAttributeName…
Z S
  • 7,039
  • 12
  • 53
  • 105
2
votes
2 answers

Index beyond bounds while setting up a cell in my table view

While setting up a cell in my table view, I had this issue: Log: * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayM objectAtIndex:]: index 5 beyond bounds [0 .. 4]' *** First throw call stack: (0x18696afd8…
sabari vasagan
  • 404
  • 5
  • 18
2
votes
1 answer

Swift UITableViewController numberOfSections index 1 beyond bounds [0 .. 0] With Static Cells

I have a UITableViewController, with a static 5 sections and 2 rows per sections, but the last section with 1 row. I've created the table in storyboards and set the number of sections and rows via storyboards. In the protocol functions I've also set…
Nick H
  • 217
  • 4
  • 19
2
votes
0 answers

[NSConcreteTextStorage attributesAtIndex:effectiveRange:]: Range or index out of bounds

I use uitextview for input text multi-line, and limit line of text input. In iOS7, app will be crash when input full text and typing multi stage character(Japanese Language). (I cannot repeat this problem but my customer said ,and it shows the error…
2
votes
1 answer

Xcode 7 beta crash on autocompletion - NSRangeException

I get this crash each time Xcode uses autocompletion. Steps - Use any system library - Ex.: UIColor I type "[UIColor col" and get a list of suggestions (colorWithCGColor - etc) I hit the delete key to get suggestions for "[UIColor co" Xcode…
Shantanu
  • 315
  • 3
  • 13
2
votes
3 answers

Swift 2.0: NSRangeException, Range or index out of bounds

Context: I come from 15-20 years of JavaScript, Ruby and (modern) PHP. I've been poking at Swift over the last year, and I'm brand-new to Cocoa. Here's a simplified test case that I'm running in Xcode 7.0 β2: #! /usr/bin/env swift import…
Ryan Parman
  • 6,855
  • 1
  • 29
  • 43
2
votes
1 answer

NSRangeException being thrown when creating a subarray using range

This is a very odd error that I'm getting. It's this: 'NSRangeException', reason: '*** -[NSArray subarrayWithRange:]: range {2, 3} extends beyond bounds [0 .. 3]' What I don't understand is that the range (2,3) clearly doesn't extent beyond the…
arc4randall
  • 3,275
  • 3
  • 27
  • 40
2
votes
2 answers

range out of bounds size 4 objective c

I have an NSString of length 4. Logically, this should work, and expYear does, but expMonth throws an out of bounds exception? expYear = [expDate substringWithRange:NSMakeRange(0, 2)]; expMonth = [expDate substringWithRange:NSMakeRange(2, 3)];
dsuma
  • 1,000
  • 2
  • 9
  • 30
2
votes
2 answers

RangeException on Array objectAtIndex #Core Data

Novice to Programming** Getting a "beyond bounds" NSRangeException when trying to access an object from a mutable array. The error is showing a long number for the objectAtIndex, but the array only currently has three objects. This is the error…
Clark
  • 416
  • 3
  • 10
2
votes
1 answer

Setting attributedText, NSRangeException error

Trying to set my UIText view's attributed text properties via selection. Almost works. Action to set text with red font color below. This works sometimes, but often gives an error: Terminating app due to uncaught exception 'NSRangeException',…
OWolf
  • 5,012
  • 15
  • 58
  • 93
1
vote
1 answer

NSRangeException from UITableViewController

I can't solve the mystery of my NSRangeException. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return…
Destron
  • 414
  • 2
  • 9
1
vote
1 answer

iOS Xcode 4.2 Master-Detail Application Template Throwing NSRangeException

Newbie question here ... I've created a Master-Detail Application project in Xcode 4.2 using ARC and Storyboard. I've modified the template to be: MasterViewController.h #import @class DetailViewController; @interface…
Mitch
  • 659
  • 1
  • 7
  • 18
1
vote
0 answers

NSRangeException - Breakpoint not giving me any clues

Forgive any errors here, I'm a coding hobbyist and a newbie to SO question asking, but have done my best to track down this bug and failed. I'm getting a crash moving between SKScenes, but only if the app has gone into, and been restored from,…
Matthew R
  • 33
  • 8
1
vote
0 answers

SceneKit error - index 0 beyond bounds for empty array

In this game, once the player dies, all of the variables are reinitialized and a tap-to-play label should appear. Instead, the app crashes with the following message: Terminating app due to uncaught exception 'NSRangeException', reason: '***…
squarehippo10
  • 1,855
  • 1
  • 15
  • 45
1
vote
2 answers

Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArray0 objectAtIndex:]: index 2 beyond bounds for empty NSArray

Error in log: * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[NSArray0 objectAtIndex:]: index 2 beyond bounds for empty NSArray' *** First throw call stack: ( 0 CoreFoundation …
sabari vasagan
  • 404
  • 5
  • 18
1
2
3
8 9