Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>as you say, the problem seems most probably to do with memory management, given the memory warnings you are receiving.</p> <p>your code is retaining a reference count to the attachmentData from the first file even as it goes out to get the zipData for the second file. internally, the picker is probably copying that data …</p> <p>so the more you can do to release your references to large data as early as possible, the more likely you are not to get the memory warnings.</p> <p>and if the problem is that the picker is unable to finish the attachment due to running out of memory, and you are able to get through it by doing early release, then breaking up the code in the following way may help you.</p> <pre><code>- (void)sendMailPicker:(MFMailComposeViewController*)picker addAttachmentUsingMimeType:(NSString*)mimeType { NSString *filePath = [self getFilePath:pType]; NSData *attachmentData = [NSData dataWithContentsOfFile:filePath]; [picker addAttachmentData:attachmentData mimeType:mimeType fileName:[filePath lastPathComponent]]; } - (void)sendMailAddPhotoUsingPicker:(MFMailComposeViewController*)picker { NSString *zipFile = [self getZipPath]; NSData *zipData = [NSData dataWithContentsOfFile:zipFile]; [picker addAttachmentData:zipData mimeType:@"application/zip" fileName:[zipFile lastPathComponent]]; } - (void)sendMail { MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; [self prepareMailPicker:picker]; NSString *mimeType; int userPhoto = [User getCSVPhoto]; switch (pType) { case EPDF: mimeType = @"application/pdf"; userPhoto = [User getPDFPhoto]; break; case ECSV: mimeType = @"text/csv"; break; case EExcel: mimeType = @"application/vnd.ms-excel"; break; default: break; } [self sendMailPicker:picker addAttachmentUsingMimeType:mimeType]; if (userPhoto == 1 &amp;&amp; shouldAddZip) { [self sendMailAddPhotoUsingPicker:picker]; } shouldAddZip = NO; [self presentModalViewController:picker animated:YES]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload