分离三个 NSString,如何?

发布于 2024-10-27 02:48:22 字数 61 浏览 2 评论 0原文

我正在连接三个字符串,并在它们之间添加“*”, 现在我想将其中三个(姓名、电子邮件、地址)分开,我该怎么做?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

最单纯的乌龟 2024-11-03 02:48:22
NSArray *components = [string componentsSeparatedByString:@"*"];

请参阅 NSString 类参考< /a> 了解更多信息。

NSArray *components = [string componentsSeparatedByString:@"*"];

See the NSString Class Reference for more information.

人心善变 2024-11-03 02:48:22

您可以使用 componentsSeparatedByString 像这样:

NSArray *seperated-strings = [yourstring componentsSeparatedByString:@"*"];

这应该会给你一个包含三个字符串的数组。

编辑:哎呀,被打败了......

You can use componentsSeparatedByString like this:

NSArray *seperated-strings = [yourstring componentsSeparatedByString:@"*"];

That should give you an array with your three strings in it.

EDIT: Whoops, got beaten to it...

Spring初心 2024-11-03 02:48:22

请注意,电子邮件地址中允许使用 * 字符,因此您应该考虑使用更强大的方法来序列化您的元组。例如 JSON

Be aware that * characters are allowed within email addresses, so you should consider using a more robust method to serialize your tuple. e.g. JSON

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文