Reputation: 7590
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.
Upvotes: 1
Views: 140
Reputation: 53950
Use the NSString methods.
You've got a lot of methods for creating substrings.
Mainly:
.substr(0, spos)
may be translated to:
[ someString substringToIndex: spos ];
Note you will first need to convert your C++ string object to a NSString object.
Upvotes: 3