可通过routerParameters获取 URL 中的参数,routerParameters[FFRouterParameterURLKey]为完整的URL.
(2)当需要通过以下方法:
+ (id)routeObjectURL:(NSString *)URL;
Route 一个 URL 并获取返回值时,需要使用如下方法注册 URL:
+ (void)registerObjectRouteURL:(NSString *)routeURL handler:(FFObjectRouterHandler)handlerBlock;
并在 handlerBlock 中返回需要返回的 Object,例如:
//注册并返回必要的值
[FFRouter registerObjectRouteURL:@"protocol://page/routerObjectDetails" handler:^id(NSDictionary *routerParameters) {
NSString *str = @“根据需要返回必要的Object”;
return str;
}];
//获取返回的值
NSString *ret = [FFRouter routeObjectURL:@"protocol://page/routerObjectDetails"];
(3)如果需要传递非常规对象作为参数,如UIImage等,可使用如下方式:
[FFRouter routeURL:@"protocol://page/routerDetails?nickname=imlifengfeng" withParameters:@{@"img":[UIImage imageNamed:@"router_test_img"]}];
2、URL Rewrite
/**
根据设置的 Rules 去 rewrite 一个 URL
@param url 将被 rewrite 的 URL
@return rewrite 后的 URL
*/
+ (NSString *)rewriteURL:(NSString *)url;
/**
添加一个 RewriteRule
@param matchRule 正则匹配规则
@param targetRule 转换规则
*/
+ (void)addRewriteMatchRule:(NSString *)matchRule targetRule:(NSString *)targetRule;
/**
同时添加多个 RewriteRule,格式必须为:@[@{@"matchRule":@"YourMatchRule",@"targetRule":@"YourTargetRule"},...]
@param rules RewriteRules
*/
+ (void)addRewriteRules:(NSArray<NSDictionary *> *)rules;
/**
移除一个 RewriteRule
@param matchRule 将被移除的 matchRule
*/
+ (void)removeRewriteMatchRule:(NSString *)matchRule;
/**
移除所有 RewriteRule
*/
+ (void)removeAllRewriteRules;
【备注】










