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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:07:25+00:00 2026-06-15T20:07:25+00:00

I want to use these lines of code from this source #define TEXTVIEW_SET_HTML_TEXT(__textView__, __text__)\

  • 0

I want to use these lines of code from this source

#define TEXTVIEW_SET_HTML_TEXT(__textView__, __text__)\
do\
{\
    if ([__textView__ respondsToSelector: NSSelectorFromString(@"setContentToHTMLString:")])\
        [__textView__ performSelector: NSSelectorFromString(@"setContentToHTMLString:") withObject: __text__];\
    else\
        __textView__.text = __text__;\
}\
while (0)

#define TEXTVIEW_GET_HTML_TEXT(__textView__, __text__)\
do\
{\
    if ([__textView__ respondsToSelector: NSSelectorFromString(@"contentAsHTMLString")])\
        __text__ = [__textView__ performSelector: NSSelectorFromString(@"contentAsHTMLString") withObject: nil];\
    else\
        __text__ = __textView__.text;\
}\
while (0)

What should I do? I am new to macros. Should i define a uitextview variable with name __textView__?? Is it possible to help me with some basic steps in order to use this code?

  • 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-15T20:07:26+00:00Added an answer on June 15, 2026 at 8:07 pm

    You just have to put your macros outside your @implementation, something like this:

    #import "..."
    
    // Put the macros here
    
    // This block may or may not be present in your code...
    @interface YourClass ()
    
    @end
    // ... up to here.
    
    @implementation YourClass
    
    @end
    

    You don’t have to declare the variables, as these are already declared in the macro. You can think of this:

    #define TEXTVIEW_SET_HTML_TEXT(__textView__, __text__)\
    do\
    {\
        if ([__textView__ respondsToSelector: NSSelectorFromString(@"setContentToHTMLString:")])\
            [__textView__ performSelector: NSSelectorFromString(@"setContentToHTMLString:") withObject: __text__];\
        else\
            __textView__.text = __text__;\
    }\
    while (0)
    

    as this C-style function:

    void TEXTVIEW_SET_HTML_TEXT(UITextView *__textView__, NSString *__text__)
    {
        do
        {
            if ([__textView__ respondsToSelector: NSSelectorFromString(@"setContentToHTMLString:")])
                [__textView__ performSelector: NSSelectorFromString(@"setContentToHTMLString:") withObject: __text__];
            else
                __textView__.text = __text__;
        }
        while (0);
    }
    

    The difference is that if you have declared it as a C-style function, it would be included in your app when it is compiled/linked. However, since it was #defined, it means the compiler would change it first to the do-while before compiling.

    You would call it like this:

    - (void)yourMethodThatWillChangeTheText
    {
        // ...
        TEXTVIEW_SET_HTML_TEXT(self.myTextView, @"Hello");
        // ...
    }
    

    As an additional info, #define is usually used to define constants, something like:

    #define PI_VALUE 3.141592
    

    which would have to be called something like:

    double circumference = 2 * PI_VALUE * radius;
    

    But as seen in the macro, it can also look/be used as a function. Thus, you have to consider how the macro/#define looks like to be sure that you call it properly.

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

Sidebar

Related Questions

I want to use these two classes from lucene - import org.apache.lucene.analysis.snowball.*; import org.apache.lucene.analysis.PorterStemmer;
I have a array of names and I want to use these names for
I have an IDictionary, now I want to use these values in a selectlist.
Now facebook require to have these options when you want to use bulit-in actions
I want to define control styles in a resource dictionary and use those for
I want to use NSString from one UIView in another UIView . There are
I want to use a linux command line tool from my Java program. I
I'm trying to use jQueryUI draggable/droppable/sortable to move (not copy) items from a source
I have a Python 3 file. I want to use an open-source tool on
I want to use an Abstract action for JFileChooser buttons because there will be

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.