Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

系统modDidCustomEvent 事件调用 #128

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
language: objective-c
xcode_project: BeeHive.xcodeproj
xcode_scheme: BeeHive
xcode_sdk: iphonesimulator
xcode_destination: platform=iOS Simulator,OS=9.3,name=iPhone 5s
30 changes: 29 additions & 1 deletion BeeHive/BHModuleManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,10 @@ - (void)handleModuleEvent:(NSInteger)eventType
BHContext *context = [BHContext shareInstance].copy;
context.customParam = customParam;
context.customEvent = eventType;

if(eventType >= BHMDidCustomEvent){ //系统自定义事件调用
[self handleModuleCustomEvent:eventType forTarget:target withContext:context andCustomParam:customParam];
}
if (!selectorStr.length) {
selectorStr = [self.BHSelectorByEvent objectForKey:@(eventType)];
}
Expand All @@ -553,6 +557,30 @@ - (void)handleModuleEvent:(NSInteger)eventType
}
}];
}

//系统modDidCustomEvent 事件
- (void)handleModuleCustomEvent:(NSInteger)eventType
forTarget:(id<BHModuleProtocol>)target
withContext:(BHContext *)context
andCustomParam:(NSDictionary *)customParam
{
SEL seletor = NSSelectorFromString(kAppCustomSelector);
NSArray<id<BHModuleProtocol>> *moduleInstances;
if (target) {
moduleInstances = @[target];
} else {
moduleInstances = [self.BHModulesByEvent objectForKey:@(BHMDidCustomEvent)];
}
[moduleInstances enumerateObjectsUsingBlock:^(id<BHModuleProtocol> moduleInstance, NSUInteger idx, BOOL * _Nonnull stop) {
if ([moduleInstance respondsToSelector:seletor]) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[moduleInstance performSelector:seletor withObject:context];
#pragma clang diagnostic pop

[[BHTimeProfiler sharedTimeProfiler] recordEventTime:[NSString stringWithFormat:@"%@ --- %@", [moduleInstance class], NSStringFromSelector(seletor)]];

}
}];
}
@end