iPhone MFMailComposeViewController 报告错误。安全吗?

发布于 2024-08-22 07:50:51 字数 2990 浏览 15 评论 0原文

在尝试使用简单的 KML 附件(仅几个字节)发送邮件时,我在发送过程中在控制台中收到以下警告。这些可以被忽略还是我犯了错误?邮件似乎发送正常,


- (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];
    }
}

我已从上面的电子邮件正文示例中删除了 HTML,因为它搞乱了 SO 格式,但它是一封基本的 HTML 电子邮件,带有指向谷歌地图的链接。

控制台中报告的警告是

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

“可能会发生坏事”——Apple 人类程序员的天哪!

我看过这个问题带音频的电子邮件报告我的错误之一。因此,我尝试将附件的 mime 类型更改为 text/xml,这没有什么区别,并完全删除附件,此时错误就消失了。

那么,这是否可能导致崩溃,或者安全吗?

In trying to send a mail with a simple KML attachemnt (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 questionemail 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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

哥,最终变帅啦 2024-08-29 07:50:51

我之前见过“无法打开锁定文件”消息,它似乎是良性的。我不知道“pipe to DADaemon”消息,这可能与邮件无关。

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.

执笔绘流年 2024-08-29 07:50:51

我在我的 MFMailComposeViewController 中收到此警告“DA|无法打开 /tmp/DAAccountsLoading.lock 处的锁定文件。无论如何,我们都会加载帐户,但可能会发生不好的事情”,因为我有

[mailViewController addAttachmentData:imageData mimeType:@ "image/png" 文件名:@""];

我只是设置了名称和扩展名。现在一切正常 =)

[mailViewController addAttachmentData:imageData mimeType:@"image/png" fileName:@"myfile.png"];

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"];

放手` 2024-08-29 07:50:51

我刚刚开始收到这些相同的消息。已在设备 iPhone OS 3.1.3 上调试,没有类似问题。

很明显,当我输入发件人的电子邮件地址时,每个警告都会弹出;对于 TO: 或 CC: 我还没有尝试过 BCC: 字段。我以前从未见过此调试器消息,我只是将可达性类添加到了 app.确定可达性方面一切工作正常,我没有更改应用程序的 MFMailComposer 部分中的任何内容,我在之前的视图控制器上启动 MFMailComposer 之前插入了 Reachability 实例。

对于我尝试输入的电子邮件地址的每个字母,我都会得到相同的 DA|pipe DADaemon 行,一旦我找到我要查找的电子邮件并单击添加它,它就会停止打印到控制台名单。不管怎样,我不喜欢收到这个警告,这不是一件好事。我关闭了附件,但它并没有删除警告。我正在导出为 html 文本,不确定这是否与此有关。我的 didFinishWithResult MFMailComposer 委托方法中没有任何额外的内容。我只是针对每种情况都有一条消息,该消息通过 AlertView 返回给用户,以告知他们的电子邮件发生了什么。

寻找解决方案!!!

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!!!

再见回来 2024-08-29 07:50:51

我赞同卡洛斯·马约拉尔的回答。就我而言,我收到此错误是因为我将 mimeType 设置为@“application/pdf”。事实证明,pdf 附件 mimeType 需要是 @"pdf" 而不是 @"application/pdf"。一旦我将其更改为“pdf”,错误就消失了。

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.

梦在深巷 2024-08-29 07:50:51

尝试用这个

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"];

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"];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文