Re: Is Concatenation that complex?
Re: Is Concatenation that complex?
- Subject: Re: Is Concatenation that complex?
- From: "Daniel Sarosi" <email@hidden>
- Date: Fri, 23 Apr 2004 13:43:30 +0800
Your top example: [NSString stringWithFormat:@"Or have we eaten on the %@
that takes", middle]; %@ stands for objects
Your second example: [NSString stringWithFormat"(%d)", cookie];
----- Original Message -----
From: "Adam" <email@hidden>
To: "Cocoa-Dev Apple" <email@hidden>
Sent: Friday, April 23, 2004 10:58 AM
Subject: Is Concatenation that complex?
>
Newbie coming from java here.
>
>
I am looking to concatenate strings. In java I could do complex string
>
concatenation mixing variables and string literals in one line:
>
>
String middle = "insane root";
>
String RelevantQuote = "Or have we eaten on the" + middle + "that takes
>
the reason prisoner?"
>
>
or in my specific less interesting case I want to end up with "(20)"
>
>
String cookie = "20";
>
String messageString2 = "(" + cookie + ")";
>
>
From what I have read in Obj-C I have to do this:
>
>
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];
>
>
It seams like a lot of work to do something simple. Is there a better
>
way?
>
>
Thanks,
>
Adam
>
>
Macbeth Act 1 Scene 3, Banquo: "Or have we eaten on the insane root
>
that takes the reason prisoner?"
>
_______________________________________________
>
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.
_______________________________________________
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.