Reputation: 17591
filepath:/var/mobile/Applications/BA7AE6F8-C7EA-4601-A5F4-30E3C57FE948/Documents/photo2.jpg photonumber:/var/mobile/Applications/BA7AE6F8-C7EA-4601-A5F4-30E3C57FE948/Documents/2
index = 2;
NSString *nextSequentialFile =
[filePath stringByReplacingOccurrencesOfString:photoNumber
withString:[NSString stringWithFormat:@"%d", index+1]
options:NSBackwardsSearch
range:NSMakeRange(0, filePath.length)];
the result is ever nextsequenzial:/var/mobile/Applications/BA7AE6F8-C7EA-4601-A5F4-30E3C57FE948/Documents/photo2.jpg
why?
it must be /photo3.jpg
Upvotes: 1
Views: 612
Reputation: 73966
filepath
doesn't contain photonumber
, so there's nothing to replace. Note that photonumber
ends with /Documents/2
while filepath
contains /Documents/photo2.jpg
.
photonumber
needs to be changed to end in /Documents/photo2
and the replacement string needs to be changed to [NSString stringWithFormat:@"/photo%d", index+1]
.
Upvotes: 1