laugh

 

 

 

//  ViewController.m
//  00-RunLoop补充
#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(execute) object:nil];
    [thread start];
}

- (void)execute
{
    CFRunLoopObserverRef observer = CFRunLoopObserverCreateWithHandler(CFAllocatorGetDefault(), kCFRunLoopAllActivities, YES, 0, ^(CFRunLoopObserverRef observer, CFRunLoopActivity activity) {
        NSLog(@"----");
    });
    
    CFRunLoopAddObserver(CFRunLoopGetCurrent(), observer, kCFRunLoopDefaultMode);
    
    CFRelease(observer);
    
//    [[NSRunLoop currentRunLoop] addPort:[NSPort port] forMode:NSDefaultRunLoopMode];
//    [[NSRunLoop currentRunLoop] addtim];
    [[NSRunLoop currentRunLoop] run];
    
    NSLog(@"------1111");
}


@end

 

分类:

技术点:

相关文章:

  • 2022-01-18
  • 2022-12-23
  • 2022-02-25
  • 2021-07-15
  • 2021-05-28
  • 2021-05-30
  • 2021-10-03
  • 2021-06-06
猜你喜欢
  • 2022-12-23
  • 2022-02-26
  • 2021-08-18
  • 2021-08-03
  • 2022-12-23
  • 2021-10-03
  • 2021-10-03
相关资源
相似解决方案