Questions tagged [nsmutablestring]

The NSMutableString class declares the programmatic interface to an object that manages a mutable string — that is, a string whose contents can be edited — that conceptually represents an array of Unicode characters.

To construct and manage an immutable string — or a string that cannot be changed after it has been created — use an object of the NSString class.

The NSMutableString () class adds one primitive method

-replaceCharactersInRange:withString:

to the basic string-handling behavior inherited from NSString . All other methods that modify a string work through this method.

More information : NSMutableString Class reference

306 questions
7
votes
4 answers

How to initialize NSString to NSMutableString?

Is there any way to initialize NSString to NSMutableString? and also reverse order? -(void)st:(NSString *)st { NSMutableString str = st; // gives warning.. NSLog(@"string: %@", str); }
user141302
6
votes
2 answers

How do I convert an NSMutableString into a regular NSString?

How can I convert a NSMutable String into a regular NSString?
user198725878
  • 6,266
  • 18
  • 77
  • 135
6
votes
1 answer

How to make an NSMutableString blank

If I have an NSMutableString containing a random string, then how do I remove all characters from it so that it becomes an empty string?
node ninja
  • 31,796
  • 59
  • 166
  • 254
6
votes
2 answers

Replace a char into NSString

I want simply replace all occourrencies of "+" with a blank " " char... I tried some sample listed here, also used NSSMutableString, but the program crash... what's the best way to replace a char from another?? thanks
ghiboz
  • 7,863
  • 21
  • 85
  • 131
6
votes
2 answers

Appending Strings to NSMutableString

Been looking at this for a bit now and not understanding why this simple bit of code is throwing an error. Shortened for brevity: NSMutableString *output; ... @property (nonatomic, retain) NSMutableString *output; ... @synthesize…
typeoneerror
  • 55,990
  • 32
  • 132
  • 223
6
votes
4 answers

Sensitive data: NSString VS NSMutableString (iPhone)

I have some sensitive data I want to clear directly after use. Currently, the sensitive data is in the form of NSString. NSString is in my understanding immutable, meaning that I can't really clear the data. NSMutableString seems more appropriate,…
AOO
  • 633
  • 11
  • 20
6
votes
2 answers

NSMutableAttributedString crashing on changing the font?

I'm sure mutable means it can be changed, so why's this happening? attrString = [[NSMutableAttributedString alloc] initWithString:@"Tip 1: Aisle Management The most obvious step – although one that still has not been taken by a disconcerting number…
dev6546
  • 1,412
  • 7
  • 21
  • 40
5
votes
1 answer

Adding multiple strings to a string

How do I add multiple strings to a string ? Whats the easiest way to do that ? If I don't want to create a new line of code every time I add something to a string, I'd like to do something like that : NSString *recipeTitle = [@"
Recipe name:…
5
votes
2 answers

Implicit conversion of a non-Objective-C pointer type 'char *' to 'NSString *' is disallowed with ARC

For the following line of code I am getting the error below: for (UILabel *label in labels) { label.text = label.tag - 100 > someMutableString.length ? "" : "*"; } The error states: Implicit conversion of a non-Objective-C pointer type 'char…
motionpotion
  • 2,656
  • 6
  • 42
  • 60
5
votes
1 answer

is it possible to rotate the character using NSAttributedString

Using NSAttributedString we can change the colour of string etc. Is it possible to tilt a specific character in a string. E.g answers will be appreciated. I found a solution which is not unto the mark. If someone corrects the code that while be…
Anand
  • 2,086
  • 2
  • 26
  • 44
5
votes
3 answers

Cocoa: NSMutableString gives warning with stringValue

This works: NSString *myVar = @"whatever"; NSDecimalNumber *myNum = [NSDecimalNumber decimalNumberWithString:@"10"]; myVar = [myNum stringValue]; This version with mutable string produces warning "assignment from distinct Objective-C…
StringSection
  • 121
  • 1
  • 5
5
votes
1 answer

How to display html content on UIWebView IOS

I have a form sheet segue that should display hard-coded html page. Now I have a two part problem first problem is

A Simple Sample Web Page

By Frodo

Demonstrating a few HTML features

is displayed like I…
Mord Fustang
  • 1,523
  • 4
  • 40
  • 71
5
votes
2 answers

Trying to use copied NSMutableString property causes an exception

I started a small Xcode project to investigate whether an NSMutableString property should be copy or retain. I declared my property with the copy attribute: @property (nonatomic,copy) NSMutableString *stringA; Then initialized it as self.stringA =…
rustylepord
  • 5,681
  • 6
  • 36
  • 49
4
votes
4 answers

NSString vs NSMutableString with stringByAppendingString

So, I'm fairly certain that if I plan on manipulating strings often, such as with stringByAppendingString, I should be using variables of type NSMutableString. But what if I'm doing something like this? UILabel *someLabel = [[UILabel alloc]…
Joseph
  • 207
  • 3
  • 10
4
votes
1 answer

Format inputed digits to US phone number to format (###) ###-####

I used this code but the issue I am having is it does not work if texfield is empty (index out of bounds) and the other issue if the user does not change the phonenumber and hit Save button it will execute the code again and insert the "((" and…
Yaroslav Dukal
  • 3,894
  • 29
  • 36
1
2
3
20 21