Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import "UIResponder+Router.h"
- @implementation UIResponder (Router)
- - (void)routerEventWithName:(NSString *)eventName userInfo:(NSDictionary *)userInfo
- {
- [[self nextResponder] routerEventWithName:eventName userInfo:userInfo];
- }
- @end
- [self routerEventWithName:kBLGoodsDetailBottomBarEventTappedBuyButton userInfo:nil];
- #pragma mark - event response
- - (void)routerEventWithName:(NSString *)eventName userInfo:(NSDictionary *)userInfo
- {
- /*
- do things you want
- */
- // call the upper ,by ResponderChain
- // [super routerEventWithName:eventName userInfo:userInfo];
- }
- #pragma mark - event response
- - (void)routerEventWithName:(NSString *)eventName userInfo:(NSDictionary *)userInfo
- {
- NSInvocation *invocation = self.eventStrategy[eventName];
- [invocation setArgument:&userInfo atIndex:2];
- [invocation invoke];
- // call the upper ,by ResponderChain
- // [super routerEventWithName:eventName userInfo:userInfo];
- }
- - (NSDictionary <NSString *, NSInvocation *> *)eventStrategy
- {
- if (_eventStrategy == nil) {
- _eventStrategy = @{
- kBLGoodsDetailTicketEvent:[self createInvocationWithSelector:@selector(ticketEvent:)],
- kBLGoodsDetailPromotionEvent:[self createInvocationWithSelector:@selector(promotionEvent:)],
- kBLGoodsDetailScoreEvent:[self createInvocationWithSelector:@selector(scoreEvent:)],
- kBLGoodsDetailTargetAddressEvent:[self createInvocationWithSelector:@selector(targetAddressEvent:)],
- kBLGoodsDetailServiceEvent:[self createInvocationWithSelector:@selector(serviceEvent:)],
- kBLGoodsDetailSKUSelectionEvent:[self createInvocationWithSelector:@selector(skuSelectionEvent:)],
- };
- }
- return _eventStrategy;
- }
Add Comment
Please, Sign In to add comment