Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7906131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:47:24+00:00 2026-06-03T10:47:24+00:00

I have a simple app, which opens a modal view to send email. Am

  • 0

I have a simple app, which opens a modal view to send email. Am using Xcode 4.2 and iOS 5, and am testing with iOS Simulator. The app crashes with
Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason:
‘Application tried to present a nil modal view controller on target
.’

when executing the line:

 [self presentModalViewController:mailComposer animated:YES];

though I have initialized the object ‘mailComposer’.

Class com_FirstViewController.m :

#import "com_FirstViewController.h"
...
@implementation com_FirstViewController
....
....
-(void)showEmailComposer {

Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
if (mailClass != nil)
{
    if ([mailClass canSendMail]) {
                    NSLog(@"showEmailComposer: Calling displayComposerSheet");
        [self displayComposerSheet];

    } else {
                    NSLog(@"showEmailComposer: Calling launchMailAppOnDevice");
        [self launchMailAppOnDevice];
    }
}
else {
            NSLog(@"showEmailComposer: Calling launchMailAppOnDevice");
    [self launchMailAppOnDevice];
}
}



#pragma mark -
#pragma mark Compose Mail

-(void) displayComposerSheet {

    mailComposer = [[MFMessageComposeViewController alloc] init];
    mailComposer.messageComposeDelegate = self;

    // Set the mail title
    [mailComposer setTitle:@"Mail Title"];

    // Set the recipients
    NSArray *toRecipients = [NSArray arrayWithObject:@"user@company.com"];

    [mailComposer setRecipients:toRecipients];

    // EMail Body
    NSString *mailBody = @"This is the mail body";
    [mailComposer setBody:mailBody];

    NSLog(@"present the modal view ctlr");
    [self presentModalViewController:mailComposer animated:YES];
}
...
...

Any pointers please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T10:47:25+00:00Added an answer on June 3, 2026 at 10:47 am
     mailComposer = [[MFMessageComposeViewController alloc] init];
    

    is the source of the problem, in my opinion. There’s no way the simulator can send SMS messages, so the initializer method may return NULL. Anyways, sou seem to be wanting to send an email, so I’d say you need to use

     mailComposer = [[MFMailComposeViewController alloc] init];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple Silverlight app which simply sets a DataGrid's ItemsSource to the
I have managed to create a simple app which deletes (bypassing the recycle bin)
I have an app i building which is a simple naviagtion app. I do
In my app, I have a simple ASCII file which stores some config info
I have one simple app that suppose to get information from user and send
i have a simple iPhone app (*.ipa), which downloaded from AppStore. I have changed
I wrote a simple Java app which I have placed in the start up
I have this script which simply kills an app KEY_NAME=/some/path kill `ps -ef |
This is a real newbie question. I have simple app that selects a picture
I have simple Sinatra app. web.rb: require 'sinatra' get '/' do Hello end Gemfile:*

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.