我是IOS开发的新手。当我运行我的应用程序时,出现以下错误。谁能帮帮我。。
我在UITextView
里面放了一个TableViewCell
. 我已将 'one\n' 设置为UITextView
.
我的代码:
- (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);
}
当我点击 时UITextView
,我选择Range
了 (3,0)。在我记录选定的范围后,我自己得到了以下异常。
例外:
2013-11-14 16:16:24.690 ZohoWriter[484:60b] ARRAY : (
0 CoreFoundation 0x2d488e9b <redacted> + 154
1 libobjc.A.dylib 0x37c3d6c7 objc_exception_throw + 38
2 CoreFoundation 0x2d488dc5 <redacted> + 0
3 Foundation 0x2de6911d <redacted> + 88
4 UIKit 0x2fdaee89 <redacted> + 328
5 UIFoundation 0x35038cd9 <redacted> + 36
6 UIKit 0x2fdaeceb <redacted> + 218
7 UIKit 0x2fdaeb79 <redacted> + 1128
8 UIFoundation 0x3501dde3 <redacted> + 46
9 UIKit 0x2fdae67b <redacted> + 222
10 UIKit 0x2fdae533 <redacted> + 54
11 UIKit 0x2fdae4d9 <redacted> + 132
12 UIKit 0x2fdac5f3 <redacted> + 2146
13 UIKit 0x2fd93739 <redacted> + 196
14 UIKit 0x2fc3e18b <redacted> + 1138
15 UIKit 0x2ffc9d4f <redacted> + 46
16 UIKit 0x2fc055cf <redacted> + 218
17 UIKit 0x2fc03d33 <redacted> + 298
18 UIKit 0x2fc3c9fd <redacted> + 772
19 UIKit 0x2fc3c3ab <redacted> + 666
20 UIKit 0x2fc11d79 <redacted> + 196
21 UIKit 0x2fc10569 <redacted> + 7116
22 CoreFoundation 0x2d453f1f <redacted> + 14
23 CoreFoundation 0x2d4533e7 <redacted> + 206
24 CoreFoundation 0x2d451bd7 <redacted> + 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 <redacted> + 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”.
我在这里做错了什么?