Iphone MFMessageController有时会崩溃
我有在我的应用程序中与联系人共享的概念,并使用MFMessageComposeViewControllerIphone MFMessageController有时会崩溃,iphone,ios7,mfmessagecomposeview,Iphone,Ios7,Mfmessagecomposeview,我有在我的应用程序中与联系人共享的概念,并使用MFMessageComposeViewController -(IBAction)btnAddClicked:(id)sender { @try { selections = [[NSMutableArray alloc] init]; for(NSIndexPath *indexPath in arSelectedRows) { NSMutableDictionary *sear
-(IBAction)btnAddClicked:(id)sender {
@try {
selections = [[NSMutableArray alloc] init];
for(NSIndexPath *indexPath in arSelectedRows) {
NSMutableDictionary *searchable = [[NSMutableDictionary alloc
]init];
[searchable setObject:[[contactsArray objectAtIndex:indexPath.row]objectForKey:@"Phone"]forKey:@"Phone"];
[selections addObject:searchable];
}
if([selections count]>0)
{
NSString *temp1=@"";
for(int i=0;i<[selections count];i++)
{
toRecepients=[[selections objectAtIndex:i]objectForKey:@"Phone"];
temp1=[temp1 stringByAppendingString:toRecepients];
temp1=[temp1 stringByAppendingString:@","];
}
temp1 = [temp1 substringToIndex:[temp1 length]-1];
if(![MFMessageComposeViewController canSendText]) {
UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Your device doesn't support SMS!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[warningAlert show];
return;
}
NSArray *recipents = [temp1 componentsSeparatedByString:@","];
MFMessageComposeViewController *messageController = [[MFMessageComposeViewController alloc] init];
messageController.messageComposeDelegate = self;
messageController.navigationBar.topItem.leftBarButtonItem.title = @"Cancel";
[messageController setRecipients:recipents];
[messageController setBody:self.message];
[self presentModalViewController:messageController animated:YES];
}
else{
UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Select the contacts you would like to share to" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[warningAlert show];
return;
}
}
@catch (NSException *exception) {
if (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone)
{
ErrorView *errorView=[[ErrorView alloc]initWithNibName:@"ErrorView" bundle:nil];
if([[[UIDevice currentDevice]systemVersion]floatValue]<5.0)
{
[self presentModalViewController:errorView animated:YES];
}
else
{
[self presentViewController:errorView animated:YES completion:nil];
}
[errorView release];
}
if (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad) {
ErrorView *errorView=[[ErrorView alloc]initWithNibName:@"ErrorView~iPad" bundle:nil];
if([[[UIDevice currentDevice]systemVersion]floatValue]<5.0)
{
[self presentModalViewController:errorView animated:YES];
}
else
{
[self presentViewController:errorView animated:YES completion:nil];
}
[errorView release];
}
} }
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult) result {
switch (result) {
case MessageComposeResultCancelled:
{
UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Failed to send SMS!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[warningAlert show];
break;
}
case MessageComposeResultFailed:
{
UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Failed to send SMS!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[warningAlert show];
break;
}
case MessageComposeResultSent:
{
NSString *messa=[NSString stringWithFormat:@"Shared to %lu contact(s)",(unsigned long)[selections count]];
UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:@"Succesful" message:messa delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[warningAlert show];
break;
}
default:
break;
}
[self dismissViewControllerAnimated:YES completion:nil];
}
我已经设置了断点进行调试,但是xcode没有显示错误产生的位置
任何想法/建议都是值得欣赏的。使僵尸对象能够找出实际崩溃的路线。
您可以通过以下步骤启用僵尸:
1.选择项目方案并选择编辑方案。2.将出现一个窗口,现在选择诊断。
3.选中“启用僵尸对象”复选标记。
现在运行您的项目。若要使用Zombie进行检查,我们无法在模拟器中为MFMessageController进行检查。因此,我也无法在设备上运行您的项目。是的,我在设备上运行了项目,但它没有显示异常点。我只是得到了该错误并停止运行。您能告诉我,我还可以应用什么来达到该错误吗([[[UIDevice currentDevice]systemVersion]floatValue]也不需要在代码中检查iPad。iOS将在iPad上自动加载
~iPad
。
Assertion failed: (result == KERN_SUCCESS), function +[XPCMachSendRight wrapSendRight:], file /SourceCache/XPCObjects/XPCObjects-46/XPCMachSendRight.m, line 27.