Hacker News new | past | comments | ask | show | jobs | submit login

The problem people have with the format implementation is that no matter what you do, it's either obtuse shorthand, or incredibly verbose.

The reality is, that NSString needs native formatting sugar. Anything else would really just be a hack. I'm not particularly even happy with the [@"Hello ":@"World] syntax, either.




Here's a crazy idea:

    newstr = [@"%d %@" format 42, @"blah"];
Implement it as a method that takes a dummy parameter, plus a macro:

    - (NSString *)format:(int)dummy, ...
    #define format format:0,
Awful way to do it, but the resulting syntax is not entirely terrible.


I'm not super comfortable with breaking message syntax like that. Also, very wary of using a #define with a short oft used keyword in a library that will be imported in majority of headers.


Exactly I just want this:

  NSString *newS = @"blah " + @(42) + @"!";




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: