IOS:HomeDirectory中的错误

时间:2011-10-14 15:46:11

标签: ios xcode home-directory

3 个答案:

答案 0 :(得分:1)

尝试:

NSString *nextSequentialFile =
[filePath stringByReplacingOccurrencesOfString:photoNumber
withString:[NSString stringWithFormat:@"%d", (index + 1)]
options:NSBackwardsSearch
range:NSMakeRange(0, filePath.length)];

答案 1 :(得分:0)

rangeOfString:photoNumber可能超出范围。我建议记录你传递给这个方法的每个值,以便判断哪个是错误的。

答案 2 :(得分:0)

永远不要假设像rangeOfString:options:这样的方法返回有效范围。来自文档:

  

返回值

     

NSRange结构,给出位置和长度   第一次出现aString的接收器,以模块中的选项为模   面具。 如果找不到aString或为空(@“”),则返回{NSNotFound,0}。

     

[强调补充]

首先获取范围并在尝试使用之前检查NSNotFound