• ios NSThred多线程简单使用


    关于NSThred开启多线程的方法

    - (void)performSelectorInBackground:(SEL)aSelector withObject:(id)arg

    [self performSelectorInBackground:@selector(doSomething) withObject:nil];

    这个方法是开启另一个线程,在 doSomething 方法中用于处理耗时的操作

    当需要UI刷新处理的时候要回到主线程:

    - (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait;

    // UI刷新
        [self performSelectorOnMainThread:@selector(refreshUI) withObject:nil waitUntilDone:NO];

    或者

    // UI刷新
        dispatch_async(dispatch_get_main_queue(), ^{
            NSLog(@"refreshUI");
        });
  • 相关阅读:
    Spinal Tap Case
    Sorted Union
    Search and Replace
    Boo who
    Missing letters
    DNA Pairing
    Pig Latin
    Where art thou
    Roman Numeral Converter
    Redis高级客户端Lettuce详解
  • 原文地址:https://www.cnblogs.com/shen5214444887/p/5604595.html
Copyright © 2020-2023  润新知