「Hej」という名前を「抽出」したいのですがNSString
、このようなものがあります。"ALAssetsGroup - Name:Hej - ProgCam, Type:Album, Assets count:0"
私はこのようにそれをやろうとしました:
NSString *sStr = [NSString stringWithFormat:@"%@", assetGroups[indexPath.row]];
NSRange range1 = [sStr rangeOfString:@"Name: "];
NSRange range2 = [sStr rangeOfString:@" - ProgCam"];
NSRange rRange = {range1.location + range1.length, range2.location};
NSString *rStr = [sStr substringWithRange:rRange];
cell.cellLabel.text = [NSString stringWithFormat:@"%@", rStr];
しかし、私はこのエラーが発生します:
*** Terminating app due to uncaught exception 'NSRangeException', reason:
'-[__NSCFString substringWithRange:]: Range or index out of bounds'
ここで何が間違っていますか?