Computer Science, asked by tapasrimallick7841, 10 months ago

How you can ""update"" an existing string ?

Answers

Answered by laraibmukhtar55
1

How can we update an existing string:

There are two options for updating an existing string:

1. By creating a new string each time with [[NSString alloc] initWithFormat:@"whatever"] and allocate it to the variable. (Make sure you follow the memory management rules, which contains making sure the string's prior value is unconfined. Of course, you'll need to trail those rules no matter how you hold this problem.)

2. Create an NSMutableString and update the string with the mutating techniques (appendFormat:, setString:, deleteCharactersInRange:, etc.). In this situation, you're not just updating the variable, but the string itself.

Hope it helped..

Answered by SerenaBochenek
0

The steps for updating an existing string is given below.

Explanation:

  • Step 1: Using [[NSString alloc] initWithFormat:@"whatever]" to establish a new sequence instead of every moment, as well as assign this one to the parameter or variable.
  • (Please ensure you obey the data storage management rules to make sure the previous value including its string becomes unconstrained. For default, you'll have to monitor those guidelines regardless of how users approach this major issue).
  • Step 2: Build an NSMutableString and then use morphing strategies to edit the sequence (appendFormat: setString: delete charactersInRange: etc.). Throughout this circumstance, you are going to update not even just the component, however the string of its own.

Learn more:

https://brainly.in/question/8168824

Similar questions