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

  • Home
  • SEARCH
  • 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 8124621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:30:50+00:00 2026-06-06T06:30:50+00:00

I have the following warning in my code (XCode 4.3 / iOS 4/5) –

  • 0

I have the following warning in my code (XCode 4.3 / iOS 4/5) –

Assigning to ‘id’ from incompatible type ‘MainViewController *’

The warning is raised in this section –

- (IBAction)sendInAppSMS:(id)sender
{
MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];
if([MFMessageComposeViewController canSendText])
{
    controller.body = @"A test message from http://www.macoscoders.com";
    controller.recipients = [NSArray arrayWithObjects:@"9880182343",nil];
    controller.messageComposeDelegate = self;
    [self presentModalViewController:controller animated:YES];
}
}

In particular this line –

controller.messageComposeDelegate = self;

In a bit confused as to what is wrong with my code. Googling for the Warning I found some references but I’m having difficulty in understanding the answers.

Any pointers / explanations would be greatly appreciated.

Best regards

rob

My complete .h file –

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <AudioToolbox/AudioToolbox.h>
#import <MessageUI/MessageUI.h>
#import "EasyTracker.h"

@interface MainViewController : TrackedUIViewController <MFMailComposeViewControllerDelegate> {

IBOutlet UIView *volumeSlider;  
AVPlayer *radiosound;

IBOutlet UIButton *playpausebutton;

IBOutlet UIActivityIndicatorView *activityIndicator;
NSTimer *timer;

}

@property(nonatomic, retain) AVPlayer                   *radiosound;
@property(nonatomic, retain) UIButton                   *playpausebutton;

- (void)updatebuttonstatus;

- (void)playCurrentTrack;
- (void)pauseCurrentTrack;
- (IBAction)playbutton;
- (IBAction)openMail:(id)sender;
- (IBAction)sendInAppSMS:(id)sender;

@end

Highlights from my .m file –

#import "MainViewController.h"
#import <AVFoundation/AVFoundation.h>
#import <AudioToolbox/AudioToolbox.h>
#import <MediaPlayer/MediaPlayer.h>
#import "radio99AppDelegate.h"

@implementation MainViewController



- (IBAction)sendInAppSMS:(id)sender
{
MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];
if([MFMessageComposeViewController canSendText])
{
    controller.body = @"A test message from http://www.macoscoders.com";
    controller.recipients = [NSArray arrayWithObjects:@"9880182343",nil];
    controller.messageComposeDelegate = self;
    [self presentModalViewController:controller animated:YES];
}
}

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
switch (result) {
    case MessageComposeResultCancelled:
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"SMSTester" message:@"User cancelled sending the SMS"
                                                      delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
        [alert show];
        [alert release];
    }
        break;
    case MessageComposeResultFailed:
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"SMSTester" message:@"Error occured while sending the SMS"
                                                       delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
        [alert show];
        [alert release];
    }
        break;
    case MessageComposeResultSent:
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"SMSTester" message:@"SMS sent successfully..!"
                                                       delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
        [alert show];
        [alert release];
    }
        break;
    default:
        break;
}

[self dismissModalViewControllerAnimated:YES];
}

- (IBAction)openMail:(id)sender 
{
if ([MFMailComposeViewController canSendMail])
{
    MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];

    mailer.mailComposeDelegate = self;

    [mailer setSubject:@"A Message from MobileTuts+"];

    NSArray *toRecipients = [NSArray arrayWithObjects:@"fisrtMail@example.com", @"secondMail@example.com", nil];
    [mailer setToRecipients:toRecipients];

    UIImage *myImage = [UIImage imageNamed:@"mobiletuts-logo.png"];
    NSData *imageData = UIImagePNGRepresentation(myImage);
    [mailer addAttachmentData:imageData mimeType:@"image/png" fileName:@"mobiletutsImage"]; 

    NSString *emailBody = @"Have you seen the MobileTuts+ web site?";
    [mailer setMessageBody:emailBody isHTML:NO];

    [self presentModalViewController:mailer animated:YES];

    [mailer release];
}
else
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure" 
                                                    message:@"Your device doesn't support the composer sheet" 
                                                   delegate:nil 
                                          cancelButtonTitle:@"OK" 
                                          otherButtonTitles: nil];
    [alert show];
    [alert release];
}

}

#pragma mark - MFMailComposeController delegate

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{   
switch (result)
{
    case MFMailComposeResultCancelled:
        NSLog(@"Mail cancelled: you cancelled the operation and no email message was queued");
        break;
    case MFMailComposeResultSaved:
        NSLog(@"Mail saved: you saved the email message in the Drafts folder");
        break;
    case MFMailComposeResultSent:
        NSLog(@"Mail send: the email message is queued in the outbox. It is ready to send the next time the user connects to email");
        break;
    case MFMailComposeResultFailed:
        NSLog(@"Mail failed: the email message was nog saved or queued, possibly due to an error");
        break;
    default:
        NSLog(@"Mail not sent");
        break;
}

[self dismissModalViewControllerAnimated:YES];
}

@end
  • 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-06T06:30:52+00:00Added an answer on June 6, 2026 at 6:30 am

    You are using:

    MFMailComposeViewControllerDelegate
    

    Where it should be:

    MFMessageComposeViewControllerDelegate
    

    Change here:

    @interface MainViewController : TrackedUIViewController <MFMessageComposeViewControllerDelegate> {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written following PHP code: $input=menu=1&type=0&; print $input.<hr>.ereg_replace('/&/', ':::', $input); After running above
I have the following code: $this->Permissions->updateAll( array('Permissions.user' => $newuser), array('Permissions.user' => $originaluser) ); But
I have the following code snippet in my Xcode: NSString *digit [[sender titlelabel] text];
All, I have the following code: $qry = Select * from vendor_options order by
I have a type that extends DeleteResourceAction . Eclipse gives me following warning: An
I want to have the following method not show a warning about using raw
I have the following example, compiled in VS2005, warning level 4: int main(int argc,
I have recently started using Zend Studio which has reported as warning the following
I have following code in my application: // to set tip - photo in
I have following code in my Application. Comments in my code will specify My

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.