jcb344
jcb344

Reputation: 323

NSMutableString defining and redefining

I am at a loss as hot to properly initiate a NSMutableString, I have tried:

NSMutableString *string = @"some text";

which is the same method one assigns a string to an NSString but have hade no luck. Additionally I have not been able to figure out how to redefine the string contained with the NSMutableString. I would imagine it would look something like:

string = @"new text";

Any help and code on this basic subject would be greatly appreciated. Thanks

Upvotes: 0

Views: 434

Answers (1)

Carl Norum
Carl Norum

Reputation: 224864

You want:

NSMutableString *string = [NSMutableString stringWithFormat:@"some text"];

Your examples are just making string point to a constant string, which is bad news, probably. To set the string, use:

[string setString:@"new text"];

Upvotes: 2

Related Questions