1
votes

Getting a weird Assertion Failure when presenting an email prompt in iOS

Code:

- (void)displayComposerSheet:(id)delegate withDataSource:(id )datasource {
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.navigationBar.tintColor = self.navigationController.navigationBar.tintColor;
    picker.mailComposeDelegate = delegate;
    //Use the datasource to fill in the email fields
    if ([[datasource recipients] count] > 0)
      [picker setToRecipients:[datasource recipients]];
    [picker setSubject:[datasource subject]];

    [picker setMessageBody:[datasource emailText] isHTML:[datasource isHTML]];
    [[UIWindow topMostController] presentModalViewController:picker animated:YES];
    [picker becomeFirstResponder];

    [picker release];
}

MyApp[60324:907] *** Assertion failure in -[MFMailComposeInternalViewController _endDelayingCompositionPresentation], /SourceCache/MessageUI/MessageUI-1075.10/Mail/MFMailComposeInternalViewController.m:316
1

1 Answers

0
votes

Alas the dangers of swizzling....

I had swizzled UINavigationController's pushViewController method with my own method that internally used setViewControllers. (I had been running into some threading issues where the same view controller got pushed twice.)