Obj-C String Concat
Posted November 1st, 2004 @ 01:32pm by Erik J. Barzeski
Chris is looking for a better way to concatenate strings in Objective-C than the fairly cumbersome stringByAppendingString:
. PHP uses the .
(dot) operator.
Of course, there's also [NSString stringWithFormat:@"%@", someObj];
. We've used that a few times in some of our apps.
Posted 01 Nov 2004 at 1:48pm #
I don't have any experience with Objective C, but does it have operator overloading?
Might be an easy way to get it how you want it - the '.' in PHP and Perl are basically overloads themselves, same with '+' in Java.
Posted 01 Nov 2004 at 4:01pm #
Objective-C doesn't have operator overloading.
The solution here might be to add a category or something.
Posted 01 Nov 2004 at 7:37pm #
There's no way in C (and thus Objective C) to define infix macros or functions, so you're SOL here.
If you're concatenating a lot of stuff, you should use a mutable string anyways.