Kristian Glass - Do I Smell Burning?

Mostly technical things

Types and Printf

Came across this post about printf-ing fixed-size types today and am very glad to have found macros for printf! Developing for the iPhone, with its platform-specific typedefs like NSInteger (either a long or an int), then seeing people just assuming one or the other when printf (or similar – I’m looking at you NSLog() and -[NSString stringWithFormat:]!) always pains me somewhat.

The advised solution was to upcast to long and use the specifier for that. Not bad, and nicer than the (ugly in retrospect but still preferable than doing it wrong) solution I had involving -[NSNumber numberWithInteger:] and -[NSNumber stringValue]! However, it won’t really do for fixed-size types, so it was nice to see that it was an already-solved problem!