This is what I'm using
[[remaining_string substringFromIndex:k] substringToIndex:1]
Is there a better way?
This is what I'm using
[[remaining_string substringFromIndex:k] substringToIndex:1]
Is there a better way?
See characterAtIndex
NSString *myString = @"Hello, World";
unichar myChar = [myString characterAtIndex:k];
Note that this returns a unichar
. You can use substringWithRange
(see Henrik's answer) if you want a NSString
.
And if you want a NSString this should work:
string2 = [string1 substringWithRange: NSMakeRange (k, 1)];