Skip to content

Commit 16aa11a

Browse files
committed
MOD: change singleton snippet to using GCD command.
1 parent 3788965 commit 16aa11a

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

CodeSnippets/45D5535E-44FA-491F-8E4B-3251A46D5372.codesnippet

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@
1212
<string>+(&lt;#ClassName#&gt; *) sharedInstance
1313
{
1414
static id sharedInstance = nil;
15-
if (!sharedInstance) {
16-
@synchronized(self){
17-
if (!sharedInstance) {
18-
sharedInstance = [[self alloc] init];
19-
}
20-
}
21-
}
15+
static dispatch_once_t onceToken;
16+
dispatch_once(&amp;onceToken, ^{
17+
sharedInstance = [[self alloc] init];
18+
});
2219
return sharedInstance;
2320
}</string>
2421
<key>IDECodeSnippetIdentifier</key>

0 commit comments

Comments
 (0)