I have two strings that are taken as input from a textfield in my application. I know that they are both 4 characters in length.
Is there some way I can "halve" those strings, and create two strings per original string that have two characters each?
A simple approach would be to use the NSString
substringWithRange:
method to obtain each of the pairs of characters you require.For example:
See the NSString class reference for more information.
Sure. NSString has the very useful methods "
substringToIndex:
" and "substringFromIndex:
". The magic number (index) here appears to be 2.