Errors are reported by iPhone MFMailComposeViewController. Is it safe?
In trying to send a mail with a simple KML att开发者_Python百科achemnt (just a few bytes) i'm getting the warnings below in the console during the send. Can these be ignored or have I made an error ? The mail seems to send OK
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
// Dismiss the e-mail controller once the user is done
[self dismissModalViewControllerAnimated:YES];
}
- (void) emailLocation: (CLLocation*) loc {
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"imhere" ofType:@"txt"];
NSString * kml=nil ;
NSString * finalkml=nil;
NSData * filedata=nil;
NSString * mime= @"application/vnd.google-earth.kml+xml";
if (filePath) kml = [NSString stringWithContentsOfFile:filePath];
if (kml) finalkml = [NSString stringWithFormat:kml,loc.coordinate.longitude, loc.coordinate.latitude,loc.altitude];
if (finalkml) filedata = [finalkml dataUsingEncoding:NSUTF8StringEncoding];
if (([MFMailComposeViewController canSendMail]) && (filedata))
{
MFMailComposeViewController *mcvc = [[[MFMailComposeViewController alloc] init] autorelease];
mcvc.mailComposeDelegate = self;
[mcvc setSubject:@"I'm here"];
NSString *body = [NSString stringWithFormat:@"at %f %f",loc.coordinate.latitude,loc.coordinate.longitude];
[mcvc setMessageBody:body isHTML:YES];
[mcvc addAttachmentData:filedata mimeType:mime fileName:@"imhere.kml"];
[self presentModalViewController:mcvc animated:YES];
}
else {
UIAlertView * av = [[UIAlertView alloc] initWithTitle:@"No Email" message:@"Unable to send email." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[av show];
[av release];
}
}
I've removed HTML from the email body sample above as it was messing up SO formatting but it was a basic HTML email with links to google maps.
The warnings reported in the console are
2010-02-21 14:23:38.809 DataTap[2008:850f] DA|Could not open the lock file at /tmp/DAAccountsLoading.lock. We'll load the accounts anyway, but bad things may happen 2010-02-21 14:23:41.420 DataTap[2008:207] DA|Pipe to DADaemon was lost. Search query 2147483647 is returning an error [Switching to thread 13827] 2010-02-21 14:23:44.197 DataTap[2008:207] DA|Pipe to DADaemon was lost. Search query 2147483647 is returning an error 2010-02-21 14:23:45.357 DataTap[2008:207] DA|Pipe to DADaemon was lost. Search query 2147483647 is returning an error 2010-02-21 14:23:45.855 DataTap[2008:207] DA|Pipe to DADaemon was lost. Search query 2147483647 is returning an error 2010-02-21 14:23:48.543 DataTap[2008:207] DA|Pipe to DADaemon was lost. Search query 2147483647 is returning an error 2010-02-21 14:23:48.848 DataTap[2008:207] DA|Pipe to DADaemon was lost. Search query 2147483647 is returning an error
"Bad things may happen" - blimey evidence of human programmers at Apple!
I've seen this question email with audio which reports one of my errors. Accordingly I tried changing the mime type of my attachment to text/xml which made no difference, and removing the attachment totally, at which point the errors went way.
So - is this likely to cause crashes, or is it safe ?
I've seen the "could not open lock file" message before and it appears to be benign. I don't know about the "pipe to DADaemon" message, that might not be mail-related.
I was getting this warning "DA|Could not open the lock file at /tmp/DAAccountsLoading.lock. We'll load the accounts anyway, but bad things may happen" in my MFMailComposeViewController because i had
[mailViewController addAttachmentData:imageData mimeType:@"image/png" fileName:@""];
I just set the name and extension. Everything is working now =)
[mailViewController addAttachmentData:imageData mimeType:@"image/png" fileName:@"myfile.png"];
I just started getting these same messages. Have been debugging on device iPhone OS 3.1.3 with no similar issues.
It is clear that each warning pops up as I'm typing in an email address for the sender; for both the TO: or CC: I have not attempted the BCC: field. I have never seen this debugger message before, I just added the Reachability Classes to app. Everything has been working fine for determining reachability, I did not change anything in the MFMailComposer section of the app, I plugged in the Reachability instance prior to lauching the MFMailComposer on previous viewcontroller.
I'm get the same DA|pipe DADaemon line for each letter of the email address that I'm trying to enter, It stops printing to the console as soon as I find the email that I was looking for and click to add it from the list. Either way, I don't like getting this warning, can't be a good thing. I turned off my Attachment, but it does not remove the warnings. I'm exporting as html text, not sure if that has something to do with it. I don't have anything extra in my didFinishWithResult MFMailComposer Delegate Method. I just have a message for each of the cases, that gets returned to the user via an alertView to inform what happened to their email.
Looking for Solutions!!!
I second Carlos Mayoral's answer. In my case, I was getting this error because I was setting mimeType to @"application/pdf". It turned out that pdf attachements mimeType needs to be @"pdf" not @"application/pdf". Once I changed it to "pdf", the error was gone.
Try with this
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"mytrack.kml"];
NSData *myData = [NSData dataWithContentsOfFile:path];
[picker addAttachmentData:myData mimeType:@"text/xml" fileName:@"mytrack.kml"];
精彩评论