From 0d24c57e54598adc88862c168071dde0fadfc36f Mon Sep 17 00:00:00 2001 From: shiweifu Date: Fri, 24 Apr 2015 15:11:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86router=20block=20?= =?UTF-8?q?=E4=BC=A0=E5=8F=82=E6=97=A0=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 当使用 HHRouterBlock block = [[HHRouter shared] matchBlockMerege:@"/testurl"]; 这种方式进行匹配时,得到了正确的block,然后通过block得到对象: block(@{@"name": @"abc"}); block(nil); 以上两种得到的结果没有区别,是因为在 matchBlock 的时候,并没有对aParams进行调用(但进行了预留) --- HHRouter/HHRouter.m | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/HHRouter/HHRouter.m b/HHRouter/HHRouter.m index 895afcd..2162d97 100644 --- a/HHRouter/HHRouter.m +++ b/HHRouter/HHRouter.m @@ -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 @@ -247,4 +248,3 @@ - (NSDictionary*)params } @end -