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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:13:09+00:00 2026-05-23T11:13:09+00:00

I have one NSTextView containing formatted text and embedded images like following. I want

  • 0

I have one NSTextView containing formatted text and embedded images like following.

NSTextView with formatted text and embedded image

I want convert above into plain text like following:

Hi this is test data (...picture...)This is colored text.

Thanks

  • 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-23T11:13:10+00:00Added an answer on May 23, 2026 at 11:13 am

    After trying few hours i came up with the following solution for my own requirement.Please let me know if we can have better way to do that.

    I have created NSString category with following code:

    + (NSString *)plainTextFromRTFD:(NSTextStorage *)aTextStorage 
               attachmentString:(NSString *)aString {
    
    NSString *returnString = @"";
    
    //Default value of aString, If nil
    if (aString == nil) {
        aString = @"(...Attachment...)";
    }
    
    if (aTextStorage && aString) {
    
        //Initialize NSMutableString object to hold plain text
        NSMutableString *plainText = [[NSMutableString alloc] init];
    
        //Loop through all the attributes one-by-one to identify the NSAttachment
        for(int i =0;i<[aTextStorage length];i++) {
    
            NSDictionary *attr= [aTextStorage attributesAtIndex:i effectiveRange:NULL];
    
            //Check whether attribute contains NSAttachment or not
            if ([attr objectForKey:@"NSAttachment"] != nil) {
                //Replace NSTextAttachment with attachmentString value
                [plainText appendFormat:@"%@",aString];
            } else {
                //Add character to plain text
                [plainText appendFormat:@"%@",[[[aTextStorage characters] objectAtIndex:i] string]];    
            }
        }
    
        //copy NSString from NSMutableString
        returnString = [plainText copy];
    
        //release NSMutableString
        [plainText release];
    }
    
    return [returnString stringByReplacingOccurrencesOfString:@"\n" withString:@" "];}
    

    And, i am using it like following:

    NSLog(@"%@",[NSString plainTextFromRTFD:[contentView textStorage] attachmentString:nil]);
    

    Where contentView is NSTextView.

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

Sidebar

Related Questions

I have one page which is divided into sections. Ιn each section I like
have one time consuming step that flattens a bunch of files. basically i'd like
I have one div; header, and another called headerimg containing an image. I'm trying
I have an NSTextView that I'm outputting text from NSTask. Everything works as expected
I have one difficulty. I have to put text on table border as a
I have one table like this. Age Group 20 G1 21 G2 20 G2
I have one input file which has html tag embedded in xml for example
Have one application in SVN (on unfuddle.com). Want to add a new application (related
I have one user in my database, and I want to grant to him
I have one Dropdownlist list contains like this: <select id=sample > <option value=1>FRIEND</option> <option

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.