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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:38:42+00:00 2026-06-02T08:38:42+00:00

I am trying to convert (or copy?) a NSMutableArray into a NSString . I

  • 0

I am trying to convert (or copy?) a NSMutableArray into a NSString. I guess my problem is
that I don’t really understand the structure of a NSString. After conversion I want to
attached it in email body. Here is my code:

- (IBAction)sendEmail
{
    NSLog(@"sendEmail");
    [textView resignFirstResponder];
    [textView1 resignFirstResponder];
    if ([MFMailComposeViewController canSendMail])
    {
        // set the sendTo address
        NSMutableArray *recipients = [[NSMutableArray alloc] initWithCapacity:1];
        [recipients addObject:@"example@yahoo.com"];
        MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
        controller.mailComposeDelegate = self;
        [controller setSubject:@"Iphone Game"];
        NSString *string = [string appendString:[NSString stringWithFormat:"%@", [viewArray objectAtIndex:i]]];
        [controller setMessageBody:string isHTML:NO];
        [controller setToRecipients:recipients];
        [self presentModalViewController:controller animated:YES];
        [controller release];
    }
    else 
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert"
 message:@"Your device is not set up for email." delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
        [alert show];
        [alert release];
    }
}
  • 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-02T08:38:45+00:00Added an answer on June 2, 2026 at 8:38 am

    EDIT:

    after reading your comment, it is pretty much clear that what you are trying to do is archiving/unarchiving an array containing objects of various kinds. So, you should try using:

    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:array];
    

    to get an NSData object that you can then send as an attachment with an email message (or in whatever other persistency layer you need).

    Keep in mind that this approach will work only if the objects stored in the array support the NSCoding protocol (you can check that in the reference for each type you are using: it clearly lists all the supported protocols). Considered that you say that your object are already stored as NSData, there should be no problem. Just archive the array, so you will be able to unarchive it later, if required.

    If you have some custom type that does not support NSCoding, you will need to implement it as described in Encoding and Decoding Objects.

    OLD ANSWER:

    I am not sure I understand your problem, but what about using componentsJoinedByString:

    E.g.:

    NSString *string = [viewArray componentsJoinedByString:@"\n"];
    

    Doing like this, the content of your array (provided it is made of strings) will be presented as a list of strings. If you use description, your array will be converted into a string without giving you much control on its format (it will add curly braces and other syntactic sugar).

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

Sidebar

Related Questions

I am trying to convert (or copy?) a NSMutableArray into a NSString. I guess
I'm trying to convert my implementation of quicksort into a template that can be
Trying to convert this c code into MIPS and run it in SPIM. int
I'm trying to convert a Math Formula into PHP code. You can see the
This is the Delphi code I'm trying to convert to .net: s1 := Copy
Hey, I am trying to convert NSString to a C string using cStringUsingEncoding but
I'm trying to convert [lastViewedAt] => 1329939559 into the date format YYYY-MM-DD, HH:MM ,
I'm trying to get data from multiple XML feeds and copy that data to
I'm trying to convert the following bash code into C++ using boost::iostreams: #!/usr/bin/bash (
I have a Solution that has two class libraries. I'm trying to convert the

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.