4 ms·
Objective-C has many good features - native strings is not one of them. There is no syntactic support for appending two strings by a simple '+', for example NS
by demallien 15y ago
Objective-C has many good features - native strings is not one of them. There is no syntactic support for appending two strings by a simple '+', for example NSString* myString = @"This is a " + "string.";
That simple omission introduces a large amount of pain when working with Objective-C for a large class of applications - especially web-aware, but also including code that parses files.
It's the same story with regards to regular expressions - yes there are libraries that can do the job, but they just aren't as pleasant to use as regexps are in the various scripting languages - python, ruby, perl, javascript, etc, where regular expressions are first-class
- naz 15y agoNSString *myString = @"This is a" @" string."; Adjacent string constants are concatenated by the preprocessor. Otherwise, I don't think it's too much hassle to call stringByAppendingString:.
- veidr 15y agoTrue, but adjacent string constants is a totally insane use case that essentially doesn't ever happen. I think the poster was talking about the far more common case of concatenating string variables: NSString *foo = @"Hello, " + userName + @"! (^_^)";