Ios 如何将NSMutableArray值共享给MFMailComposeViewController
我从数据库中获取值,并将这些值分配给NSMuatbleArray。然后将值数组共享到邮件中。如何与setMessgaeBody共享值:Ios 如何将NSMutableArray值共享给MFMailComposeViewController,ios,objective-c,sqlite,mfmailcomposeviewcontroller,social-framework,Ios,Objective C,Sqlite,Mfmailcomposeviewcontroller,Social Framework,我从数据库中获取值,并将这些值分配给NSMuatbleArray。然后将值数组共享到邮件中。如何与setMessgaeBody共享值: if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL) == SQLITE_OK) { // We "step" through the results - once for each row. while (sqlite3_step(statement) == SQLITE_ROW)
if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL) == SQLITE_OK) {
// We "step" through the results - once for each row.
while (sqlite3_step(statement) == SQLITE_ROW) {
sk_code = [[NSString alloc] initWithUTF8String:
(const char *) sqlite3_column_text(statement, 4)];
NSLog(@"sk_code %@",sk_code);
[product_sku_array addObject:sk_code];
// To address
NSArray *toRecipents = [NSArray arrayWithObject:@"test@gmail.com"];
MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
// mailController.mailComposeDelegate = self;
[mailController setSubject:@"Test"];
[mailController setMessageBody:product_sku_array isHTML:NO];
[mailController setToRecipients:toRecipents];
[self presentViewController:mailController animated:YES completion:nil];
}
NSLog:
product_sku_array (
123
)
sk_code test1
product_sku_array (
123,
test1
)
temp inside is 123,test1
正确初始化阵列,然后使用
[mailController setMessageBody:[product_sku_array componentsJoinedByString:@“,“]isHTML:NO]
[mailController setMessageBody:
接受字符串参数,因此
获取NSMutableString并将每个数组对象附加到单个字符串中
像
字符串=[string appendString:[NSString stringWithFormat:%@,[array]
对象索引:i]]]
然后将该字符串设置为消息体,如
[mailController setMessageBody:string isHTML:NO]
我只从数组中获取第一个值。product_sku_数组(123,test1)我只得到123个值,没有得到test1nsstring*temp=[product_sku_数组组件通过字符串连接:@“,”;检查临时字符串并检查数组。如果临时状态良好,则使用[mailController setMessageBody:temp isHTML:NO];