/** 在主线程执行block */

+ (void)gs_synExecuteOnMainThread:(void (^)(void))block {

    if ((nil == block) || (NULL == block)) {

        return;

    }

    if ([NSThread isMainThread]) {

        block();

    }else {

        dispatch_sync(dispatch_get_main_queue(), ^{

            block();

        });

    }

}

 

/** 在异步主线程执行block */

+ (void)gs_asynExecuteOnMainThread:(void (^)(void))block {

    if ((nil == block) || (NULL == block)) {

        return;

    }

    dispatch_async(dispatch_get_main_queue(), ^{

        block();

    });

   }

相关文章:

  • 2021-04-29
  • 2022-12-23
  • 2022-12-23
  • 2021-08-23
  • 2021-12-05
  • 2021-10-12
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-03
  • 2022-12-23
相关资源
相似解决方案