简体   繁体   中英

separate three NSStrings, how?

我正在连接三个字符串,并且在其中插入了“ *”,现在我想将三个字符串(名称,电子邮件,地址)分开,该怎么办?

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

有关更多信息,请参见《 NSString类参考 》。

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...

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM