我正在尝试获取文本视图的第一句话。我有以下代码,但出现越界错误。谢谢你。或者有什么方法不是很复杂。
-(IBAction)next:(id)sender
{
NSRange ran = [[tv.text substringFromIndex:lastLocation] rangeOfString:@". "];
if(ran.location != NSNotFound)
{
NSString * getRidOfFirstHalfString = [[tv.text substringFromIndex:lastLocation] substringToIndex:ran.location];
NSLog(@"%@",getRidOfFirstHalfString);
lastLocation+=getRidOfFirstHalfString.length;
}