• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Is Concatenation that complex?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >Is Concatenation that complex? (From: Adam <email@hidden>)

  • Prev by Date: Re: Is Concatenation that complex?
  • Next by Date: Pop email checking information?
  • Previous by thread: Re: Is Concatenation that complex?
  • Next by thread: Re: Is Concatenation that complex?
  • Index(es):
    • Date
    • Thread