如何分隔数字字符串以发送批量短信 [英] how to separate numbers string to send bulk sms

查看:70
本文介绍了如何分隔数字字符串以发送批量短信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一次向多个号码发送短信.

i need to send sms to multiple numbers at a time.

我正在使用MFMessageComposeViewController发送短信.

to send sms i am using MFMessageComposeViewController.

我放置一个文本字段并将该文本字段文本作为收件人传递.

i place a text field and pass that textfield text as recipients.

现在我需要一次将其发送到多个号码.

now i need to send it to multiple numbers at a time.

为此,我认为将放置为手机号码的分隔符.

for that i think by placing the , as separator for mobile number.

例如:9292929292,92929292992,9292929292.

eg:9292929292,92929292992,9292929292.

在发送时,我需要将每个号码分开.

At the sending time i need to separate each and individual number.

我该怎么做

任何人都可以帮助我.

预先感谢你.

推荐答案

如果按照消息提示,您有一个用逗号分隔的字符串,则只需在逗号上分割该字符串,然后在您的收件人属性中设置结果数组:

If you have a string separated by commas as your message suggests, you can just split the string on the commas and set the resulting array in your recipients property:

// assume messageController is your MFMessageComposeViewController instance
NSString* numbersToSendString = @"929292,929292,929292";
NSArray* numbersToSend = [numbersToSendString componentsSeparatedByString:@","];
NSLog(@"numbers:");
[numbersToSend enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL* stop){
  NSLog(" object %lu: %@", (unsigned long) idx, obj);
}];
[messageController setReceipients:numbersToSend];
// ... continue whatever

这篇关于如何分隔数字字符串以发送批量短信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆