2011-11-14 9 views

答えて

5

使用NSString方法pathComponentspathWithComponents:今

NSString *p = @"/img/david/PlayBasketball.jpg"; 

NSMutableArray *cmps = [NSMutableArray arrayWitharray:[p pathComponents]]; 
// cmps will be: ["/", "img", "david", "PlayBasketball.jpg"] 

[cmps insertObject:@"HIRes" atIndex:2]; 
// You want index 2 because "/" is at index 0, and "img" is at index 1. 

NSString *newPath = [NSString pathWithComponents:cmps]; 
// The pathWithComponents method will add the rest of the "/"'s for you 

newPathは次のようになります。@"/img/HiRes/david/PlayBasketball.jpg"

関連する問題