私はバーコードアプリに取り組んでおり、CLControllerから場所を取得しているので、場所、速度、その他多くのことを指定しているので、WithRangeをサブストリングして例外を取得しているので、理由とこれをどうすればよいですか?
前もって感謝します。
- (void)locationUpdate:(CLLocation *)location {
locstr = [location description ];
//NSLog(@"current location is %@ ",locstr);
NSString* regexString =@"<(.*?)>";
NSRegularExpressionOptions options = NSRegularExpressionCaseInsensitive;
NSError* error = NULL;
NSRegularExpression* regex = [NSRegularExpression regularExpressionWithPattern:regexString options:options error:&error];
if (error) {
//NSLog(@"error is %@", [error description]);
}
NSArray* results = [regex matchesInString:locstr options:0 range:NSMakeRange(1, [locstr length])];
for (NSTextCheckingResult* result in results) {
resultString = [locstr substringWithRange:result.range];
//NSLog(@"%@",resultString);
//life = [[resultString substringWithRange:NSMakeRange(1)] retain];
resultString =[resultString substringWithRange:NSMakeRange(1,27)];
resultString = [resultString stringByReplacingOccurrencesOfString:@" "
withString:@""];
life = [resultString stringByReplacingOccurrencesOfString:@"+"
withString:@""];
life = [[life substringWithRange:NSMakeRange(0,[life length]-1)] retain];
//NSLog(@"in update %@",life);
}
}
この例外を取得する
2011-11-23 14:24:58.161 BarCodeApp [2632:707] *キャッチされなかった例外'NSRangeException'、理由:'-[NSRegularExpression enumerateMatchesInString:options:range:usingBlock:]:範囲またはインデックスが範囲外であるためにアプリを終了しています'最初のスローコールスタック:(0x326398bf 0x364a31e5 0x326397b9 0x326397db 0x3783846b 0x37838a11 0x37af 0xbe73 0x3548f5df 0x3548ef81 0x3548962f 0x3260db3 データフォーマッタは一時的に利用できません。「続行」後に再試行します。(dlopen関数が見つからないため、共有ライブラリをロードできません。)