我有这个代码
NSString *nextSequentialFile =
[filePath stringByReplacingOccurrencesOfString:photoNumber
withString:[NSString stringWithFormat:@"%d", (index + 1)]
options:NSBackwardsSearch
range:[filePath rangeOfString:photoNumber options:NSBackwardsSearch]];
但是我有这个错误,我不明白,因为它发生了。
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFString replaceOccurrencesOfString:withString:options:range:]: Range or index out of bounds'
最佳答案
尝试:
NSString *nextSequentialFile =
[filePath stringByReplacingOccurrencesOfString:photoNumber
withString:[NSString stringWithFormat:@"%d", (index + 1)]
options:NSBackwardsSearch
range:NSMakeRange(0, filePath.length)];
关于IOS:主目录错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7770135/