Skip to content

Commit

Permalink
Merge pull request clayallsopp#18 from aelam/master
Browse files Browse the repository at this point in the history
fixed error if explicitly define initWithRouterParams
  • Loading branch information
clayallsopp committed Dec 6, 2013
2 parents 2029cd9 + 6e37fc9 commit 335a013
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Routable/Routable.m
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ @interface UPRouter ()
#define ROUTE_NOT_FOUND_FORMAT @"No route found for URL %@"
#define INVALID_CONTROLLER_FORMAT @"Your controller class %@ needs to implement either the static method %@ or the instance method %@"

#define CONTROLLER_CLASS_SELECTOR @selector(controllerWithRouterParams:)
#define CONTROLLER_SELECTOR @selector(initWithRouterParams:)

@implementation UPRouter

@synthesize navigationController = _navigationController;
Expand Down Expand Up @@ -308,8 +305,12 @@ - (NSDictionary *)paramsForUrlComponents:(NSArray *)givenUrlComponents
}

- (UIViewController *)controllerForRouterParams:(RouterParams *)params {
SEL CONTROLLER_CLASS_SELECTOR = @selector(controllerWithRouterParams:);
SEL CONTROLLER_SELECTOR = @selector(initWithRouterParams:);
UIViewController *controller = nil;
Class controllerClass = params.routerOptions.openClass;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
if ([controllerClass respondsToSelector:CONTROLLER_CLASS_SELECTOR]) {
controller = [controllerClass performSelector:CONTROLLER_CLASS_SELECTOR withObject:[params getControllerParams]];
}
Expand All @@ -322,7 +323,7 @@ - (UIViewController *)controllerForRouterParams:(RouterParams *)params {
controller = nil;
}
}

#pragma clang diagnostic pop

if (controller == nil) {
@throw [NSException exceptionWithName:@"RoutableInitializerNotFound"
Expand Down

0 comments on commit 335a013

Please sign in to comment.