Currently I am working on a piece of software, which is currently written 100% in Objective-C using the iPhone 3.0 SDK.
I have come to a cross roads where I need to do quite a bit or string concatenation, more specifically, NSString concatenation and so far I have been doing it like this:
Objective-C string concatenation:
NSString *resultantString = (NSMutableString*)[@"Hello " stringByAppendingString: @"World"];
Now as you can imagine this gets quite difficult to read when I try to concatenate 6 NSStrings together.
At first I contemplated mixing in an Objective-C++ class to do my string concatenation and hand it back to my Objective-C class as then I could use C++'s easy string concatenation like:
C++ string concatenation:
string cppString = "Hello" + "World" + "see" + "easy!";
I could use C char arrays but that would be a little more difficult to read.
It then struck me that I could use a Python or Ruby bridge in Cocoa (which provide the added bonus of Regular expressions and superior string handling than the C based languages do).
This made sense to me even though I have coded only small amounts of Ruby and Python, because they are billed as string manipulation languages. Perl I decided to skip because it isn't directly supported in Xcode.
I am also interested in performance, so I am looking for the fastest way to do my string concatenation.
So what should I do? Is there some deviously easy way I am missing in Objective-C to concatenate many strings at once say 10 strings? or is my idea to use Python or Ruby class methods that return a concatenated or regex modified strings not as incredibly insane as it sounds? Perhaps I even missed some another way to do this?
Update: Yes. It seems I was rather crazy for thinking of pulling in another language runtime to do string manipulation, especially since I noted that I was concerned with speed. Adding a bridge would probably be much slower than simply using NSString/NSMutableString.