Re: Is Concatenation that complex?
Re: Is Concatenation that complex?
- Subject: Re: Is Concatenation that complex?
- From: "M. Uli Kusterer" <email@hidden>
- Date: Fri, 23 Apr 2004 06:42:00 +0200
At 22:58 Uhr -0400 22.04.2004, Adam wrote:
NSString* cookieString = [[NSString alloc]
initWithFormat:@"%d", cookie];
NSString* pClose = @")";
NSString* pOpen = @"(";
NSString* CookiePOpen = [pOpen
stringByAppendingString:cookieString];
NSString* PCloseCookiePOpen = [CookiePOpen
stringByAppendingString:pClose];
NSString* messageString2 = [messageString
stringByAppendingString:PCloseCookiePOpen];
The solution the others have offered is the shortest one, but just
for completeness' sake, you could also have written the above as:
NSString* cookieString = [NSString stringWithFormat: @"%d", cookie];
NSString* messageString = [cookieString stringByAppendingString: @")"];
NSString* messageString2 = [@"(" stringByAppendingString: messageString];
Or even:
NSString* finalString = [@"(" stringByAppendingString: [[NSString
stringWithFormat: @"%d", cookie] stringByAppendingString: @")"]];
Especially that you can just send a message to a constant string,
while logical, may not be obvious.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.