Adding zip as an attachment to MFMailComposerViewController crashes in iOS

I have an application in which I attach a zip file to a mail composer. I am using the code below to attach a zip file.

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *writableDBPath= [documentsDirectory stringByAppendingPathComponent:@"Records.zip"]; NSData *data = [NSData dataWithContentsOfFile: writableDBPath]; [picker addAttachmentData:data mimeType:@"application/zip" fileName:@"/Records.zip"]; 

File in the document directory: /var/mobile/Applications/46348DAA-9B4B-4DA8-98E0-3CEF880D2721/Documents/Records.zip

I am stuck in NSData *data = [NSData dataWithContentsOfFile:WritableDBPath]; I do not know what's the problem.

When I can install zip, I get a warning about getting memory *** - [_ UIRemoteViewControllerConnectionRequest save]: message was sent to the freed instance 0x1cd04690.

Please help me.

+4
source share
1 answer

I tried the same code for another device and its performance. I think this is a device problem. I tried with two new devices and worked great.

+1
source

All Articles