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 4320540
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:38:44+00:00 2026-05-21T08:38:44+00:00

I have done a search for this problem, and have not found an answer,

  • 0

I have done a search for this problem, and have not found an answer, which is leading me to write my firs tquestion here.

The problem is when I press the button which calls the metho below, I get an exception on this line: [self presentModalViewController:mailViewController animated:YES]; and the exception is:

* Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[NSCFString count]: unrecognized selector sent to instance 0x20f6c’

In addition, I am running my app on the simulator if that helps.

I got the magority of the code from here.

Here is my code (with the email address blanked out):

    // set up the email address array
    NSArray *email = [[NSArray alloc] initWithObjects:@"foo", nil];

    // Set up the view controller
    MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
    mailViewController.mailComposeDelegate = self;

    // Set up the email to send to
    [mailViewController setSubject:@"foo"];
    [mailViewController setToRecipients:[email objectAtIndex:0]];

    // Get the path to the plist
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentsPath = [paths objectAtIndex:0];  
    NSString *path = [documentsPath stringByAppendingPathComponent:@"foo.plist"];

    // Get the plist from the path
    NSData *myData = [NSData dataWithContentsOfFile:path];
    [mailViewController addAttachmentData:myData mimeType:@"plist" fileName:@"foo"];

    // Fill out the email body text 
    NSString *emailBody = @"Attached PLIST file";
    [mailViewController setMessageBody:emailBody isHTML:NO];

    // Release the array
    [email release];

    if (mailViewController != nil) {
        [self presentModalViewController:mailViewController animated:YES];
        [mailViewController release];
    }

What appears to be causing the exception?

  • 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-05-21T08:38:45+00:00Added an answer on May 21, 2026 at 8:38 am

    In setToRecipients you have to specify an array, not a string. So you could pass your email-array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have search throughout this site to find a answer to my problem and
I found this perl script here which seems will work for my purposes. It
First to clarify, I have already done a search and found a few identical
I have done this a lot of times but I have a problem, I'm
I have done a bit of testing on this myself (During the server side
I have done a bit of research into this and it seems that the
I have done this: $ z() { echo 'hello world'; } How do I
I have done jQuery and Ajax, but I am not able to get the
I have done some work with Ruby on Rails but am still not comfortable
Simple problem, though apparently not a simple solution. Example here: http://myhideout.eu/new/ Basically the site

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.