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

BHModule排序问题 #105

Open
rjinxx opened this issue Jan 22, 2018 · 0 comments
Open

BHModule排序问题 #105

rjinxx opened this issue Jan 22, 2018 · 0 comments

Comments

@rjinxx
Copy link

rjinxx commented Jan 22, 2018

BHModule同时通过Annotation和plist两种方式注册的没有统一到一起根据modulePriority排序,而是分别各自排序的。这里是否应该是不管用何种方式注册的,最后都统一根据modulePriority排序后放到BHModules的Array中?

我这边是这么改的,不知道是否可行?

  1. 在addModuleFromObject: shouldTriggerInitEvent:函数调用[self.BHModuleInfos addObject:moduleInfo]后把kModuleInfoPriorityKey也加到self.BHModuleInfos里去:

        if ([moduleInstance respondsToSelector:@selector(modulePriority)]) {
            [moduleInfo setObject:@([moduleInstance modulePriority])
                           forKey:kModuleInfoPriority];
        }
    
  2. 这时registedAllModules里面的self.BHModuleInfos就是完整的排过序的集合,这边的[self.BHModules addObjectsFromArray:tmpArray]改成下面的方法,直接往self.modules插入未初始化的moduleInstance,插入顺序根据self.BHModuleInfos的顺序来:

            id<BHModuleProtocol> moduleInstance = [[moduleClass alloc] init];
            NSUInteger index = [self.moduleInfos indexOfObject:module];
            if (index == NSNotFound || index > [self.modules count]) {
                [self.modules addObject:moduleInstance];
            } else {
                [self.modules insertObject:moduleInstance atIndex:index];
            }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant