Note that there are some explanatory texts on larger screens.

plurals
  1. POTerminating app due to uncaught exception NSInvalidArgumentException , reason: The index is invalid
    text
    copied!<p>I'm new to IOS development. When i run my app ,i got the following error. Could anyone help me..</p> <p>I have placed an <code>UITextView</code> inside a <code>TableViewCell</code>. And i have set 'one\n' as text of the <code>UITextView</code>.</p> <p><strong>My Code :</strong></p> <pre><code>- (id)initWithFrame:(CGRect)frame withIndexPath:(NSArray *)indexPath { self = [super initWithFrame:frame]; if (self) { mIndexPath = indexPath; mRange = NSMakeRange(0,4); self.delegate = self; self.attributedText = @"one\n"; self.scrollEnabled = NO; } return self; } - (void)textViewDidBeginEditing:(TextView *)textView { [self updateRangeForSelection]; } - (void)updateRangeForSelection { NSRange selectedRange = self.selectedRange; NSLog(@"%d",selectedRange.location); } </code></pre> <p>When i tap on the <code>UITextView</code>, I got the selected <code>Range</code> as (3,0). After i logging the selected Range, Myself got the following exception. </p> <p><strong>ExCeption:</strong></p> <pre><code>2013-11-14 16:16:24.690 ZohoWriter[484:60b] ARRAY : ( 0 CoreFoundation 0x2d488e9b &lt;redacted&gt; + 154 1 libobjc.A.dylib 0x37c3d6c7 objc_exception_throw + 38 2 CoreFoundation 0x2d488dc5 &lt;redacted&gt; + 0 3 Foundation 0x2de6911d &lt;redacted&gt; + 88 4 UIKit 0x2fdaee89 &lt;redacted&gt; + 328 5 UIFoundation 0x35038cd9 &lt;redacted&gt; + 36 6 UIKit 0x2fdaeceb &lt;redacted&gt; + 218 7 UIKit 0x2fdaeb79 &lt;redacted&gt; + 1128 8 UIFoundation 0x3501dde3 &lt;redacted&gt; + 46 9 UIKit 0x2fdae67b &lt;redacted&gt; + 222 10 UIKit 0x2fdae533 &lt;redacted&gt; + 54 11 UIKit 0x2fdae4d9 &lt;redacted&gt; + 132 12 UIKit 0x2fdac5f3 &lt;redacted&gt; + 2146 13 UIKit 0x2fd93739 &lt;redacted&gt; + 196 14 UIKit 0x2fc3e18b &lt;redacted&gt; + 1138 15 UIKit 0x2ffc9d4f &lt;redacted&gt; + 46 16 UIKit 0x2fc055cf &lt;redacted&gt; + 218 17 UIKit 0x2fc03d33 &lt;redacted&gt; + 298 18 UIKit 0x2fc3c9fd &lt;redacted&gt; + 772 19 UIKit 0x2fc3c3ab &lt;redacted&gt; + 666 20 UIKit 0x2fc11d79 &lt;redacted&gt; + 196 21 UIKit 0x2fc10569 &lt;redacted&gt; + 7116 22 CoreFoundation 0x2d453f1f &lt;redacted&gt; + 14 23 CoreFoundation 0x2d4533e7 &lt;redacted&gt; + 206 24 CoreFoundation 0x2d451bd7 &lt;redacted&gt; + 630 25 CoreFoundation 0x2d3bc471 CFRunLoopRunSpecific + 524 26 CoreFoundation 0x2d3bc253 CFRunLoopRunInMode + 106 27 GraphicsServices 0x320d02eb GSEventRunModal + 138 28 UIKit 0x2fc71845 UIApplicationMain + 1136 29 ZohoWriter 0x000bea1d main + 116 30 libdyld.dylib 0x38136ab7 &lt;redacted&gt; + 2 ) 2013-11-14 16:16:24.695 ZohoWriter[484:60b] Exception : The index 4 is invalid 2013-11-14 16:16:24.696 ZohoWriter[484:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'The index 4 is invalid' terminating with uncaught exception of type NSException Program received signal: “SIGABRT”. </code></pre> <p>What i'm doing wrong here ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload