Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Objective-C's incredibly verbose syntax for array and hash manipulation is my number one pain point with the language. A little syntactic sugar would go a long way here.


Try this set of macros that adds some syntactic sugar to obj c: https://github.com/petejkim/ConciseKit

For example, this:

  [NSDictionary dictionaryWithObjectsAndKeys:v1, k1, v2, k2, nil]
Turns into:

  $dict(v1, k1, v2, k2)


This looks promising, thanks for the tip.

I didn't know you could use $ in macros. Does the C preprocessor accept any other special characters?


It's actually a GNU C extension to the set of legal identifier characters.


Unfortunately XCode's definition of word characters doesn't include $, so cmd-double-click on an identifier like $dict doesn't work. Anyone know a fix?




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

Search: