Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • Cool! I still think the Util above is a much more elegant solution; you can append only one string with this macro, right? Commented Jul 18, 2009 at 13:02
  • 1
    True, the AS macro above does one append per line of code. If multiple appends are a common need, then more macros can be created. For example, a macro to append two strings: <pre> #define A2S(A,B,C) [[(A) stringByAppendingString:(B)] stringByAppendingString:(C)] </pre> Commented Jul 18, 2009 at 23:54
  • 2
    Or, simply shorten the typing required with a macro like "#define AS stringByAppendingString", then just use "AS" where your would normally type "stringByAppendingString", and enjoy multiple appends per line of code. Commented Jul 19, 2009 at 0:02
  • 15
    The problem with these macros is that they undermine one of the major goals of Objective-C, which is readability. It's extremely unclear what "AS" does. Saving a few keystrokes (most of which are handled with autocompletion) at the expense of readability is seldom a good trade-off. There are exceptions (the @"" syntax is much more readable than having to use +stringWithUTF8String: every time), but the goal should still be readability rather than simply brevity. You write once, but you debug forever. Commented Feb 16, 2010 at 14:42
  • Hi Rob - I can't agree with you in this. Sure, "AS" is a bad name. It should be named perhaps "CAT". Commented Dec 18, 2015 at 2:49