Objective-C 中的子字符串
我正在将一个示例从 C 转换为 Objective-C,并且有一个问题。
C/C++ 指令:
buffer[i].str = population[i1].str.substr(0, spos) + population[i2].str.substr(spos, esize - spos);
如何
使用 .substr(0, spos) Buffer 和 Population 来翻译 .substr(0, spos) 部分的向量。 str 是一个字符串变量 i、i1、i2、spos 和 esize 是整型变量。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 NSString 方法。
您有很多创建子字符串的方法。
主要是:
.substr(0, spos)
可以翻译为:注意,您首先需要将 C++ 字符串对象转换为 NSString 对象。
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.