2010-01-31 59 views
0

当我插入这段代码时,它会产生一个错误,我该如何处理没有错误的事件?错误日志SIGABRT如何解决它?

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{ 
switch (result) 
    { 
     case MFMailComposeResultCancelled: 
      URLCacheAlertWithError(@"Result: canceled"); 
      //message.text = @"Result: canceled"; 
      break; 
     case MFMailComposeResultSaved: 
      URLCacheAlertWithError(@"Result: saved"); 
      //message.text = @"Result: saved"; 
      break; 
     case MFMailComposeResultSent: 
      URLCacheAlertWithError(@"Result: sent"); 
      //message.text = @"Result: sent"; 
      break; 
     case MFMailComposeResultFailed: 
      URLCacheAlertWithError(@"Result: failed"); 
      //message.text = @"Result: failed"; 
      break; 
     default: 
      URLCacheAlertWithError(@"Result: not sent"); 
     // message.text = @"Result: not sent"; 
      break; 
    } 
} 

2010-01-31 22:07:05.638 iPortals[1678:207] *** -[NSCFString localizedDescription]: unrecognized selector sent to instance 0x38474 
2010-01-31 22:07:05.643 iPortals[1678:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString localizedDescription]: unrecognized selector sent to instance 0x38474' 
2010-01-31 22:07:05.649 iPortals[1678:207] Stack: (
    844776241, 
    843056877, 
    844780055, 
    844282517, 
    844245696, 
    20767, 
    12345, 
    807831445, 
    807768071, 
    807781201, 
    844553639, 
    807717485, 
    844537573, 
    851058789, 
    851397973, 
    844537573, 
    851058789, 
    851058693, 
    851058647, 
    851057969, 
    851060293, 
    851056221, 
    851054649, 
    851040559, 
    851039143, 
    848378745, 
    844528685, 
    844526429, 
    848374975, 
    848375147, 
    850798447, 
    850793587, 
    9135, 
    9068 
) 
terminate called after throwing an instance of 'NSException' 
Program received signal: “SIGABRT”. 

回答

1

这意味着,你发出的信息localizedDescription0x38474一个对象,它是NSCFString类的对象不支持此消息。

您可能打算将此方法发送给另一个有指向的对象,但未保留此对象(可能是自动释放的)。然后它会自动释放,并向指针(变量名称)发送消息,但其他一些方法已将对象放置在同一地址。

+0

我更新了一些代码,使我的帖子发生错误 感谢您的回复Felix – RAGOpoR 2010-01-31 15:16:44

+0

上述方法看起来不错。你可以发布函数URLCacheAlertWithError。 – FelixLam 2010-01-31 15:25:57

+0

我看到我知道我使用URLCacheAlertWithError的错误参数 导致错误 再次感谢Felix – RAGOpoR 2010-01-31 15:30:49