Hello, I've been struggling with this issue for a few days. I am trying to use the MFMailComposeController to send emails. What's happening is that the program crashes (long stack-trace below) upon clicking the SEND button. However, this is non-deterministic - sometimes it works immediately, sometimes after a long delay, and most often, it crashes. Here's my code for sending:
-(void)mailWithAttachment:(NSString *) fileName
type:(NSString*) attachmentType
data:(NSData *) attachmentData {
MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
mc.mailComposeDelegate = self;
if ([MFMailComposeViewController canSendMail]) {
[mc setSubject:@"my subject"];
[mc setMessageBody:@"my body" isHTML:YES];
[mc addAttachmentData:attachmentData
mimeType:attachmentType
fileName:fileName];
[self presentModalViewController:mc animated:YES];
}
[mc release];
}
didFinish result looks like you'd imagine:
-(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
[self dismissModalViewControllerAnimated:YES];
//...some other actions here for other UI logic, but problem persists if removed
}
And the definition of the class:
@interface ShareViewController : UIViewController { //... }
Here's the stack trace:
#0 0x33568534 in gdb_objc_debuggerModeFailure
#1 0x3356634e in _rwlock_write_nodebug
#2 0x33560940 in map_images
#3 0x2fe0413e in __dyld__ZN4dyldL18notifyBatchPartialE17dyld_image_statesbPFPKcS0_jPK15dyld_image_infoE
#4 0x2fe042d4 in __dyld__ZN4dyldL11notifyBatchE17dyld_image_states
#5 0x2fe0aee0 in __dyld__ZN11ImageLoader4linkERKNS_11LinkContextEbbRKNS_10RPathChainE
#6 0x2fe062d6 in __dyld__ZN4dyld4linkEP11ImageLoaderbRKNS0_10RPathChainE
#7 0x2fe08188 in __dyld_dlopen
#8 0x30c18fd0 in dlopen
#9 0x0000390c in <function called from gdb>
#10 0x3356628e in getMethodNoSuper_nolock
#11 0x335662b8 in _class_getMethodNoSuper_nolock
#12 0x3356518a in lookUpMethod
#13 0x33562914 in _class_lookupMethodAndLoadCache
#14 0x3356264a in objc_msgSend_uncached
#15 0x33562a2a in _class_initialize
#16 0x33567dfe in prepareForMethodLookup
#17 0x33565168 in lookUpMethod
#18 0x33562914 in _class_lookupMethodAndLoadCache
#19 0x3356264a in objc_msgSend_uncached
#20 0x32b2c288 in +[NSTimeZone(NSTimeZone) defaultTimeZone]
#21 0x32b2c246 in -[NSCalendarDate initWithTimeIntervalSinceReferenceDate:]
#22 0x32b3beb4 in -[NSDate(NSCalendarDateStuff) descriptionWithCalendarFormat:timeZone:locale:]
#23 0x323642fc in -[NSDate(Goodies) descriptionForMimeHeaders]
#24 0x32a6e812 in -[MailComposeController headersUseSuspendInfo:]
#25 0x32a71e38 in -[MailComposeController messageUseSuspendInfo:endingEditing:]
#26 0x32a6e594 in -[MailComposeController _getMessage:]
#27 0x32a6e536 in -[MailComposeController message]
#28 0x32a72bcc in -[MailComposeController deliverMessageRemotely]
#29 0x32a7cab0 in -[_MFMailComposeRootViewController mailComposeControllerCompositionFinished:]
#30 0x32a6e0a0 in -[MailComposeController sendMessage]
#31 0x32a7086a in -[MailComposeController send:]
#32 0x32c29ffa in -[NSObject performSelector:withObject:]
#33 0x32a661cc in -[MailComposeView _sendButtonClicked:]
I've tried the MFMailComposeController as a child of different views with the same result. Can anyone advise? I'd really appreciate it!