objective c - More efficient way of stringByReplacingOccurrencesOfString -


is there more efficient way of stripping string of undesirable phrases, in case image extensions? understand it's possible use nscharacterset used here: replace multiple characters in string in objective-c? whole phrases?

    nsstring *title = [imagepath lastpathcomponent];     title = [title stringbyreplacingoccurrencesofstring:@".jpg" withstring:@""];     title = [title stringbyreplacingoccurrencesofstring:@".jpeg" withstring:@""];     title = [title stringbyreplacingoccurrencesofstring:@".png" withstring:@""];     title = [title stringbyreplacingoccurrencesofstring:@".jpg" withstring:@""];     title = [title stringbyreplacingoccurrencesofstring:@".jpeg" withstring:@""];     title = [title stringbyreplacingoccurrencesofstring:@".png" withstring:@""]; 

there's method in nsstring called -stringbydeletingpathextension can used delete extension follows:

nsstring *title = [imagepath lastpathcomponent]; nsstring *titleminusextension = [title stringbydeletingpathextension]; 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -