Greetings, NSHipsters!
As we prepare to increment our NSDateComponents -year
by 1
, it's time once again for NSHipster end-of-the-year Reader Submissions! Last year, we got some mind-blowing tips and tricks. With the release of iOS 7 & Mavericks, and a year's worth of new developments in the Objective-C ecosystem, there should be a ton of new stuff to write up for this year.
Submit your favorite piece of Objective-C trivia, framework arcana, hidden Xcode feature, or anything else you think is cool, and you could have it featured in the year-end blowout article. Just comment on this gist below!
Here are a few examples of the kind of things I'd like to see:
- Using
NSStringFromSelector(@selector())
as a safer way to do KVC / KVO / NSCoding. - Panic's rather surprising discovery about the internals of the Lightning Digital AV Adapter
- This brilliant write-up deriving block syntax from C declarators by @nilsou, or @lazerwalker's more to-the-point site, "Fucking Block Syntax"
Can't wait to see what y'all come up with!
A quick-and-dirty way to debug any instance - at any point during execution, without waiting to hit a breakpoint - is to NSLog the memory address in the object's initializer method:
NSLog(@"<%@>: %p", NSStringFromClass([self class]), self);
(example:<XXFooView>: 0xDEADBEEF
)Once that prints, make note of the memory address (in the example above, it's
0xDEADBEEF
).Now, whenever you feel like it, you can hit the Pause execution button and type this in the debugger:
po 0xDEADBEEF
and the
description
of that object will print in the debugger.