I need help filtering NSStrings. Suppose I have a string called myString.
NSString *myString = @"HelloWorld";
How can I filter the word “Hello” out of it. Or how can I remove a specific amount of letters (Which it is beginning with) if I wanted to remove the first five letters.
Another example of what I’m facing:
NSString *myString = @"Hello hi World";
Similarly, I want to remove “Hello” and the space after that. Another time I might want to remove the two words “Hello hi” and the space after that so that only “World” is left.
Please can someone explain the basics of removing characters in NSStrings? I am totally new to the world of objective-c and reading the class-reference made me even more confused. I’m only 12 so don’t be harsh on me for not understanding the class-reference.
For this case you need a NSMutableString:
Explanation for NSMakeRange: First you go to the end of the string and count back the length (11). Now you´re on the “H”-character. Now you delete the following six characters. “World” is now left over.