arunkumar.p
arunkumar.p

Reputation: 1775

Iphone 4 MFmailcompose viewcontroller crash

     Iphone 4 MFMailComposeViewController 



     MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
    controller.mailComposeDelegate = self;
    [controller setMessageBody:@"Welcome" isHTML:NO];
    [controller release];

  My app to be crash.
  Wat i  did wrong

Regards, Arun

Upvotes: 0

Views: 572

Answers (4)

DHamrick
DHamrick

Reputation: 8488

The mail composer will crash if the user is unable to send mail. First check to see if the user is able to send mail before trying to instantiate a MFMailComposeViewController.

if([MFMailComposeViewController canSendMail])
{
   MFMailComposeViewController* controller = [[[MFMailComposeViewController alloc] init] autorelease];
   //...

}

Upvotes: 2

Akira Takahashi
Akira Takahashi

Reputation: 3012

init failed, because not iOS mail-application's setting.

MFMailComposeViewController* controller = [[[MFMailComposeViewController alloc] init] autorelease];
if (!controller) // failed
    return; // auto view alert, "not mail setting..."
controller.mailComposeDelegate = self;

Upvotes: -1

KatokichiSoft
KatokichiSoft

Reputation: 954

As Akira says, you can use MFMailComposeViewController after you set up the device's e-mail settings.

Upvotes: 0

arunkumar.p
arunkumar.p

Reputation: 1775

@Arun , First up all configure the email settings in your device

Upvotes: 0

Related Questions