Let say Your String is "HelloRabbit"
NSString *aString = @"HelloRabbit"
First Way
NSString *substring = [aString substringToIndex:7];
You will get: "HelloRab"
It mean you take the first character until the 7th character
Second Way
NSString *substring = [aString substringFromIndex:5];
You will get "Rabbit"
It mean you take from the 5th character until the end
You will get "Rab"
It mean you start from character 5 and take only 3 character
Amazing, in java its one overloaded method called, guess what? SUBSTRING()
ReplyDeletewhy oh why...