将文件添加到NSMutableArray中

时间:2011-06-28 14:45:47

标签: file nsmutablearray

我想按一下按钮将xml文件保存到文档目录中,然后将该文件添加到一个数组中,稍后该数组将被发送到一个电子邮件地址。我想我已经找到了保存,但是如何将文件放入数组?也可以以某种方式将这些文件发送到电子邮件地址?有人可以就此提出一些建议吗?

1 个答案:

答案 0 :(得分:0)

NSString *filePath = @"...<path to directory where XML is saved on the device>";

NSMutableArray *mArray = [[NSMutableArray alloc] init];

//Repeat this for every file you want to attach
[mArray addObject:filePath];

执行此操作后......每当需要发送带附件的电子邮件时,循环遍历数组并将其添加为附件。 使用此作为参考。 http://iosdevelopertips.com/email/how-to-send-email-with-attachments-example-using-iphone-camera-to-email-a-photo.html

这适用于图像,但对于任何经过修改的文件都适用。