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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:32:52+00:00 2026-05-28T18:32:52+00:00

How would I go about adding text to a UITextView without replacing the previous

  • 0

How would I go about adding text to a UITextView without replacing the previous text?

So far I have a UITextView and a UIButton that adds the text to the UITextView, but I would like the text field to append more text every time you hit the button instead of completely deleting the text and replacing it.

  • 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-28T18:32:52+00:00Added an answer on May 28, 2026 at 6:32 pm

    Here are some ways to overcome obstacles in iOS development:

    1. Look at the documentation for the particular class you’re trying to manipulate. In this case, UITextView documentation can be found within Xcode or online.

    2. Command-Click on UITextView or any other object anywhere in your code, and it will bring you to the header file for that class. The header file will list every public method and property.

    3. Look at your existing code. I’m assuming that since you have a button that adds text to a UITextView, you understand how to set its text. 99% of the time you’ll find that any setter (mutator) methods will have a corresponding getter (accessor) method. In this case, UITextView has a method called setText: and a matching method just called text.

    Finally, NSString has a convenience method called stringWithFormat: that you can use to concatenate (join) two strings, among other very useful things. %@ is the format specifier for a string. For example, to combine two strings, stringOne and stringTwo, you could do the following:

    NSString *string = [NSString stringWithFormat:@"%@ %@", stringOne, stringTwo];

    I will leave you to come up with the answer as to how to combine NSString stringWithFormat: and UITextField text and setText: to achieve what you’d like to accomplish.


    Edit:
    The OP was unable to figure out how to utilize the information above so a complete code sample has been provided below.

    Assume you have synthesized property (possibly an IBOutlet) UITextView that you have initialized called myTextView. Assume also that we are currently in the method scope of the method that gets called (your IBAction, if you’re using IB) when you tap your UIButton.

    [myTextView setText:[NSString stringWithFormat:@"%@ %@", myTextView.text, @"this is some new text"]];
    

    Explanation: myTextView.text grabs the existing text inside of the UITextView and then you simply append whatever string you want to it. So if the text view is originally populated with the text “Hello world” and you clicked the button three times, you would end up with the following progression:

    Initial String: @”Hello world”
    Tap one: @”Hello world this is some new text”
    Tap Two: @”Hello world this is some new text this is some new text”
    Tap Three: @”Hello world this is some new text this is some new text text this is some new text”

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

Sidebar

Related Questions

I have a text field entry in my view that I would like to
How would I go about adding enctype=multipart/form-data to a form that is generated by
I would like to know how I would go about altering the HTML that
I have a subclassed NSView that I would like to contain an editable NSTextField,
How would one go about adding a submenu item to the windows explorer context
How would I go about adding the Spent Time as a column to be
How would I go about adding a dynamic .......... to a restaurant menu in
How would someone go about adding check boxes to only the children of a
How would I go about dynamically adding commas as a user is entering numbers?
How would I go about adding an opaque logo to the background of a

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.