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 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
Here is my problem: I have a sequence S of (nonempty but possibly not
Im not quite sure what to search for to sort out this problem. I
I found this perl script here which seems will work for my purposes. It
I have done this a lot of times but I have a problem, I'm
First to clarify, I have already done a search and found a few identical
I am using google Api for custom search and have done the json Parsing.
Have done some research and found some stuff that may be helpful. I would
I have done some research, and majority of the examples I have found use
I have done this operation millions of times, just using the + operator! I

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.