Skip to content

Commit

Permalink
add HHRouteType.
Browse files Browse the repository at this point in the history
Add HHRouteType.
  • Loading branch information
chenyihu committed May 22, 2015
1 parent f1e0774 commit a7e908a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions HHRouter/HHRouter.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
/// @name HHRouter
///---------------

typedef NS_ENUM (NSInteger, HHRouteType) {
HHRouteTypeNone = 0,
HHRouteTypeViewController = 1,
HHRouteTypeBlock = 2
};

typedef id (^HHRouterBlock)(NSDictionary *params);

@interface HHRouter : NSObject
Expand All @@ -40,6 +46,8 @@ typedef id (^HHRouterBlock)(NSDictionary *params);
- (HHRouterBlock)matchBlock:(NSString *)route;
- (id)callBlock:(NSString *)route;

- (HHRouteType)canRoute:(NSString *)route;

@end

///--------------------------------
Expand Down
15 changes: 15 additions & 0 deletions HHRouter/HHRouter.m
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,21 @@ - (void)map:(NSString *)route toControllerClass:(Class)controllerClass
subRoutes[@"_"] = controllerClass;
}

- (HHRouteType)canRoute:(NSString *)route
{
NSDictionary *params = [self paramsInRoute:route];

if (params[@"controller_class"]) {
return HHRouteTypeViewController;
}

if (params[@"block"]) {
return HHRouteTypeBlock;
}

return HHRouteTypeNone;
}

@end

#pragma mark - UIViewController Category
Expand Down

0 comments on commit a7e908a

Please sign in to comment.