Skip to content

Commit

Permalink
@synchronized is replaced by GCD dispatch_once, coz it is way more cl…
Browse files Browse the repository at this point in the history
…eaner, awesome and recommended by apple.
  • Loading branch information
jeslyvarghese committed Mar 20, 2014
1 parent 57f9f16 commit 0b2b16b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions HHRouter/HHRouter.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ @implementation HHRouter

+ (instancetype)shared
{
static HHRouter *router;
@synchronized(self) {
static HHRouter *router = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if (!router) {
router = [[self alloc] init];
}
}
});
return router;
}

Expand Down Expand Up @@ -126,6 +127,7 @@ - (NSArray *)pathComponentsFromRoute:(NSString *)route

- (NSString *)stringFromFilterAppUrlScheme:(NSString *)string
{
//filter out the app URL compontents.
for (NSString *appUrlScheme in [self appUrlSchemes]) {
if ([string hasPrefix:[NSString stringWithFormat:@"%@:", appUrlScheme]]) {
return [string substringFromIndex:appUrlScheme.length + 1];
Expand Down

0 comments on commit 0b2b16b

Please sign in to comment.