IOS:主目录错误

标签 ios xcode home-directory

我有这个代码

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/

相关文章:

ios - UIBarButtonItem 改变播放/暂停按钮的图像

ios - 定义与 Swift 2.0 中的先前值冲突

path - 惯用地在 Rust Path 中展开波浪号

iphone - 在 iPhone 中使用 Flurry 展示广告

ios - 从链接打开应用程序时,appsflyer 深度链接不起作用(未调用委托(delegate)方法)

java - 我可以在 Xcode 中运行 Java 小程序吗?

GnuPG 主目录

c++ - 如何使用 C++ 以跨平台方式找到用户的主目录?

iphone - 有没有一种安全的方法可以手动为 UIScrollView 的滚动设置动画?

ios 无法识别的选择器发送到实例