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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:01:37+00:00 2026-05-24T01:01:37+00:00

As the user types into my textfiled I want the new characters to inherit

  • 0

As the user types into my textfiled I want the new characters to inherit the previous attributes.

I currently get the attributes from the previous character and add it as new attribute for the new range? How can I make it so that it extends the previous attributedString instead?

// What I have
"a"{attribute1 (0,1)} "b"{attribute2 (1,1)} "c"{attribute3(2,1)}
// What I'm trying to do
"abc" {attribute1 (0,3)}

Note: This has to happen for every character that the user types, so as the user type the new character should inherit the previous attributes.

EDIT:
More info

// So I create a new AttributedString, added it to my mutable string
NSAttributedString *newString = [[NSAttributedString alloc] initWithString:USER_INPUT attributes:self.defaultAttributes];
[_mutableAttributedString insertAttributedString:newString atIndex:selectedNSRange.location];

// Is it possible to add the USER_INPUT to the end of my mutable attributedString and extends the range of the previous attribute?
  • 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-24T01:01:38+00:00Added an answer on May 24, 2026 at 1:01 am

    You can use the replaceCharactersInRange:withString: method to do this. If the length of the specified range is 0, no characters will be replaced. The string will be automatically given the attributes of the character before it, unless it is at the beginning, in which case it will be given the attributes of the character after it.

    NSRange range = NSRangeMake([_mutableAttributedString length],0);
    [_mutableAttributedString replaceCharactersInRange:range withString:USER_INPUT];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UILabel that shows a character count as the user types into
I have a textfield where the user can type what ever he want into
I'm trying to select dynamic ids when a user types something into the input
if a user types in an input say 3 into a text box three
I want that whenever the user types http://localhost:8280/services/Facebook/sea the actual request should be http://localhost:8280/services/Facebook/search?q=jack
I'm adding some user feedback mechanism into my app. The user types some comments
what i have is a textbox into which the user types a string. The
This is my code for inserting into database from textfields. SqlConnection Connection = new
When a user types into my edittext the text is a bit small, Id
I have a textarea. After the user types X number of characters in 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.