I’m translating an example from C to Objective-C and have a questions.
C/C++ instruction:
buffer[i].str = population[i1].str.substr(0, spos) + population[i2].str.substr(spos, esize - spos);
How can I translate the part .substr(0, spos)
Buffer and population are vector using .
str is a string variable
i, i1, i2, spos and esize are integer variables.
Use the NSString methods.
You’ve got a lot of methods for creating substrings.
Mainly:
.substr(0, spos)may be translated to:Note you will first need to convert your C++ string object to a NSString object.