我正在向电子邮件发送声音文件,但我只想为电子邮件更改其名称。
假设我拿了一些sound.caf
,在我的文件夹中,我想留下它的名字,但是要复制它,更改它的名字,然后发送它。
我将展示我如何发送电子邮件,我需要最简单的方法来更改文件名而不影响原始文件名:
//send email log-------------------------
NSLog(@"mail");
[[CCDirector sharedDirector] pause];
picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
NSArray *toRecipients = [NSArray arrayWithObject:@"your email"];
[picker setToRecipients:toRecipients];
NSString *sound=[NSString stringWithFormat:@"sound%d.caf",[memoryInstnace getSoundToEdit]]; //here, i need to change the name of the copy .
NSArray *paths2 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *dataPath = [[paths2 objectAtIndex:0] stringByAppendingPathComponent:sound];
NSData *data = [NSData dataWithContentsOfFile:dataPath];
[picker addAttachmentData:data mimeType:@"caf" fileName:sound];//
NSString *emailBody = @"my sound ";
[picker setMessageBody:emailBody isHTML:NO];
[picker setSubject:@" new message "];
//display the view
[[[CCDirector sharedDirector] view] addSubview:picker.view];
//[[CCDirector sharedDirector] stopAnimation];
[[CCDirector sharedDirector] pause];