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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:58:48+00:00 2026-06-03T03:58:48+00:00

When I convert my NSMutableArray Into NSdata,I get NSMutableArray data in bytes. Now I

  • 0

When I convert my NSMutableArray Into NSdata,I get NSMutableArray data in bytes.
Now I want To convert it into UIImage, because I want to send My Array data by Email, but I get null in UIImage.

Here is my code.

     NSData *data = [NSKeyedArchiver archivedDataWithRootObject:viewArray];
      UIImage *image = [UIImage imageWithData:data];
      [controller addAttachmentData:image mimeType:@"image/png"
             fileName:@"labelData"];
  • 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-03T03:58:49+00:00Added an answer on June 3, 2026 at 3:58 am

    To convert an image to string you need a method to convert NSData to a base64Encoded string and back (lots of examples http://cocoadev.com/wiki/BaseSixtyFour). The easiest ones to use are categories on NSData so you can do something like this:

    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:viewArray];
    NSString* pictureDataString = [self base64EncodingWithLineLength:data];
    UIImage* image = [UIImage imageWithData:[NSData 
            dataFromBase64EncodedString: pictureDataString]];
    [controller addAttachmentData:image mimeType:@"image/png"
             fileName:@"labelData"];
    
    
    - (NSString *) base64EncodingWithLineLength:(NSData*) data {
    
    const unsigned char* bytesArr=[data bytes];
    unsigned int lineLength=0;
    NSMutableString *result = [NSMutableString stringWithCapacity:[data length]];
    unsigned long ixtext = 0;
    unsigned long lentext = [data length];
    long ctremaining = 0;
    unsigned char inbuf[3], outbuf[4];
    unsigned short i = 0;
    unsigned short charsonline = 0, ctcopy = 0;
    unsigned long ix = 0;
    
    while( YES ) {
        ctremaining = lentext - ixtext;
        if( ctremaining <= 0 ) break;
    
        for( i = 0; i < 3; i++ ) {
            ix = ixtext + i;
            if( ix < lentext ) inbuf[i] = bytesArr[ix];
            else inbuf [i] = 0;
        }
    
        outbuf [0] = (inbuf [0] & 0xFC) >> 2;
        outbuf [1] = ((inbuf [0] & 0x03) << 4) | ((inbuf [1] & 0xF0) >> 4);
        outbuf [2] = ((inbuf [1] & 0x0F) << 2) | ((inbuf [2] & 0xC0) >> 6);
        outbuf [3] = inbuf [2] & 0x3F;
        ctcopy = 4;
    
        switch( ctremaining ) {
            case 1:
                ctcopy = 2;
                break;
            case 2:
                ctcopy = 3;
                break;
        }
    
        for( i = 0; i < ctcopy; i++ )
            [result appendFormat:@"%c", encodingTable[outbuf[i]]];
    
        for( i = ctcopy; i < 4; i++ )
            [result appendString:@"="];
    
        ixtext += 3;
        charsonline += 4;
    
        if( lineLength > 0 ) {
            if( charsonline >= lineLength ) {
                charsonline = 0;
                [result appendString:@"\n"];
            }
        }
    }
    
    return [NSString stringWithString:result];
    }
    
    
    
    
    static char encodingTable[64] = {
    'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
    'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
    'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
    'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/' };
    

    Try this way may help you out.

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

Sidebar

Related Questions

I want to convert the contents of NSMutableArray to NSData and then convert it
i want to write NSString into NSMutableArray.Please look at the following code: NSData *returnData
i am trying to convert array object into string but still it is returning
I want to convert a view ID into a URL using EL. The purpose
I have a NSMutableArray I get by loading a plist into it. The date
I want to make an array of Unicode characters, but I don't know how
I am trying to convert (or copy?) a NSMutableArray into a NSString . I
hi all how to convert NSMutableArray values into the NSString when i did as
I am trying to convert (or copy?) a NSMutableArray into a NSString. I guess
I have an NSMutableArray i am trying to convert into a string. Declaring 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.