Re: NSString newbie question
Re: NSString newbie question
- Subject: Re: NSString newbie question
- From: Paul Lynch <email@hidden>
- Date: Wed, 15 Mar 2006 16:21:36 +0000
On 15 Mar 2006, at 16:07, Bobby B wrote:
NSString * myStr = @"Rating: (";
NSString * myStr1 = [myStr stringByAppendingString:[ratingOutlet
stringValue]];
NSString * myStr2 = [myStr1 stringByAppendingString:@"/10)"];
[ratingTextOutlet setStringValue:myStr2];
It seems that the only way I can get what I want is to declare a new
nsstring variable each time I need to append something.
My way:
NSString *myStr = @"Rating: (";
myStr = [myStr stringByAppendingString:[ratingOutlet stringValue]];
myStr = [myStr stringByAppendingString:@"/10)"];
[ratingTextOutlet setStringValue:myStr];
NSMutableString sounds great (and it is), but it's for when you want
to change the contents of the string, not for simple string
manipulations like the above. Of course, I'd probably do your
example differently, as:
[NSString stringWithFormat:@"Rating: (%@/10)", [ratingOutlet
stringValue]];
Plus localisation, etc.
Paul
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden