Skip to content

Commit

Permalink
修复了router block 传参无效的问题
Browse files Browse the repository at this point in the history
当使用

  HHRouterBlock block = [[HHRouter shared] matchBlockMerege:@"/testurl"];

这种方式进行匹配时,得到了正确的block,然后通过block得到对象:

block(@{@"name": @"abc"});

block(nil);

以上两种得到的结果没有区别,是因为在 matchBlock 的时候,并没有对aParams进行调用(但进行了预留)
  • Loading branch information
shiweifu committed Apr 24, 2015
1 parent dc187c7 commit 0d24c57
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions HHRouter/HHRouter.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,16 @@ - (HHRouterBlock)matchBlock:(NSString*)route
{
NSDictionary* params = [self paramsInRoute:route];
HHRouterBlock routerBlock = [params[@"block"] copy];
HHRouterBlock returnBlock = ^id(NSDictionary* aParams)
{
HHRouterBlock returnBlock = ^id(NSDictionary* aParams) {
if (routerBlock) {
return routerBlock([params copy]);
}
return nil;
};
NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:params];
[dic addEntriesFromDictionary:aParams];
return routerBlock([NSDictionary dictionaryWithDictionary:dic].copy);
}
return nil;
};

return [returnBlock copy];
return [returnBlock copy];
}

- (id)callBlock:(NSString*)route
Expand Down Expand Up @@ -247,4 +248,3 @@ - (NSDictionary*)params
}

@end

0 comments on commit 0d24c57

Please sign in to comment.