views:

45

answers:

1

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

+2  A: 

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"];
Carl Norum
thanks for the response, unfortunatly i tryed the following code an the compiler gives me the error: initializer element is not constanton the line:NSMutableString *url_of_server=[NSMutableStringstringWithFormat:@"http://111.111.1.1:80/file"];Any ideas?
jcb344
@jcb344 you can't have a method invocation in a global variable declaration. If you need a global `NSMutableString`, set it up in your `awakeFromNib` or something.
Carl Norum