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

dispatch_queue_async_rjbk went wrong in viewDidLoad #14

Open
zljkevin opened this issue Jun 1, 2018 · 1 comment
Open

dispatch_queue_async_rjbk went wrong in viewDidLoad #14

zljkevin opened this issue Jun 1, 2018 · 1 comment
Labels

Comments

@zljkevin
Copy link

zljkevin commented Jun 1, 2018

In application: didFinishLaunchingWithOptions:

 UITabBarController *tabVC = (UITabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
    UITabBarItem *mineItem = tabVC.tabBar.items.lastObject;
    NSString *minePath = @"root.mine";
    
    mineItem.badgeOffset = CGPointMake(5, 5);
    
    [self.badgeController observePath:minePath badgeView:mineItem block:^(id _Nullable observer, NSDictionary<NSString *,id> * _Nonnull info) {
        NSLog(@"%@",info);
    }];
    
    NSString *mineMessagePath = @"root.mine.message";
    
    [RJBadgeController setBadgeForKeyPath:mineMessagePath count:9];

In MineViewController viewDidLoad

    NSString *mineMessagePath = @"root.mine.message";
    [self.badgeController observePath:mineMessagePath badgeView:self.navigationItem.leftBarButtonItem block:^(id _Nullable observer, NSDictionary<NSString *,id> * _Nonnull info) {
        NSLog(@"%@",info);
    }];

leftBarButtonItem in MineViewController did not show the badge, caused by dispatch_queue_async_rjbk did not execute the code!

Use

dispatch_async(dispatch_get_main_queue(), ^{
});

instead.

@zljkevin
Copy link
Author

zljkevin commented Jun 1, 2018

iOS 11.3.1, Xcode9.4 ,iPhone8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants