分离三个 NSString,如何?
我正在连接三个字符串,并在它们之间添加“*”, 现在我想将其中三个(姓名、电子邮件、地址)分开,我该怎么做?
I am joining three strings and in between of them "*" is putted,
now I want to separate three of them (Name, Email, Address), how can I do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请参阅 NSString 类参考< /a> 了解更多信息。
See the NSString Class Reference for more information.
您可以使用 componentsSeparatedByString 像这样:
这应该会给你一个包含三个字符串的数组。
编辑:哎呀,被打败了......
You can use componentsSeparatedByString like this:
That should give you an array with your three strings in it.
EDIT: Whoops, got beaten to it...
请注意,电子邮件地址中允许使用
*
字符,因此您应该考虑使用更强大的方法来序列化您的元组。例如 JSONBe aware that
*
characters are allowed within email addresses, so you should consider using a more robust method to serialize your tuple. e.g. JSON