我有用戶在文檔目錄...在一個UITableView顯示的記錄文件...附加在文件目錄locatted郵寄的iOS的Xcode
我把這個代碼在我的didSelectRowAtIndexPath方法錄製文件的.caf。 ..爲什麼這不工作?
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fileName = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",[directoryContents objectAtIndex:indexPath.row]]];
NSURL *audioURL = [NSURL URLWithString:fileName];
NSData *audioData = [NSData dataWithContentsOfURL:audioURL];
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;
[mailer addAttachmentData:audioData mimeType:@"audio/caf" fileName:fileName];
你是否已經在調試器中檢查了代碼,以確保這些引用都不是零? – matt
是的...調試器是空白的......它應該是? – iDevMartin
所以你不知道如何使用調試器?學會使用它會很好!它向您顯示所有這些引用(路徑,documentsDirectory,fileName等)的值,以便您可以看到它們是否符合您的期望。只是通過代碼可能會解決您的問題。否則,你是通過猜測編程... – matt