Skip to content

Instantly share code, notes, and snippets.

@mattt
Created November 26, 2012 13:59
Show Gist options
  • Star 35 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save mattt/4148342 to your computer and use it in GitHub Desktop.
Save mattt/4148342 to your computer and use it in GitHub Desktop.
NSHipster Call for Tips & Tricks!

Howdy howdy, NSHipsters!

If you alloc init an NSCalendar, you'll notice that New Year's Eve falls on a Monday this year, a.k.a. "the day NSHipster is published every week". What fun!

So in celebration of the upcoming year++, I thought it'd be fun to compile a list of some of your favorite tips and tricks of the trade. 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:

Again, just comment on this Gist below with your submission.

Can't wait to see what y'all come up with!

@SlaunchaMan
Copy link

How about associated objects? You know it’s going down when you see this at the top of one of my files:

#import <objc/runtime.h>

static const void *kMyKey = &kMyKey;

@shpakovski
Copy link

In iOS 6 you can animate a constant property in NSLayoutConstraint:

viewConstraint.constant = ConstantValueFrom;
[view layoutIfNeeded];

viewConstraint.constant = ConstantValueTo;
[view setNeedsUpdateConstraints];

[UIView animateWithDuration:ConstantAnimationDuration animations:^{
     [view layoutIfNeeded];
}];

@0xced
Copy link

0xced commented Dec 3, 2012

Printing NSCache usage information (tested on iOS only):

extern void cache_print(void *cache);

- (void) printCache:(NSCache *)cache
{
    cache_print(*((void **)(__bridge void *)cache + 3));
}

Use for debugging only!

@mattt
Copy link
Author

mattt commented Dec 31, 2012

Thanks again, everyone, for your great submissions! These have now been compiled into this special New Year's Eve Edition of NSHipster. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment