Skip to content

Instantly share code, notes, and snippets.

@unclebean
Created November 21, 2014 02:08
Show Gist options
  • Save unclebean/faa12772248abe241af4 to your computer and use it in GitHub Desktop.
Save unclebean/faa12772248abe241af4 to your computer and use it in GitHub Desktop.
Define static NSDictionary, but when second invoke will be crash. For fixing that we must set "onceToken=0" for pre-invoke getStaticInfo before.
static NSDictionary *inst = nil;
static dispatch_once_t onceToken = 0;
+(NSDictionary *) getStaticInfo{
dispatch_once(&onceToken, ^{
inst = @{
@"": @[]
};
});
return inst;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment