Skip to content

Instantly share code, notes, and snippets.

@radex
Created February 14, 2013 18:30
Show Gist options
  • Save radex/4955049 to your computer and use it in GitHub Desktop.
Save radex/4955049 to your computer and use it in GitHub Desktop.
Add that to a class that you want to use as a singleton object across multiple XIB files. If you have an init method, you might want to make sure you don't re-initialize the object that's already been initialized. Warning: feels like magic
+ (id) allocWithZone:(NSZone *)zone
{
static id globalInstance;
if(!globalInstance)
{
globalInstance = [super allocWithZone:zone];
}
return globalInstance;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment