nsthread

    0热度

    1回答

    我想使用NSThread的子类来运行一些命令。在您推荐NSOperation或GCD之前,是的,我需要使用线程。 下面是我的代码和我的输出。该块正在创建并添加到数组中,据推测该数组正在出队并由该线程运行,但我没有看到由块运行产生的任何输出。为什么不? import UIKit class ViewController: UIViewController { private let

    1热度

    3回答

    我的应用程序使用NSInputStream象下面这样: inputStream.delegate = self; [inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; [readStream open]; 和委托: - (void)stream:(NSStr

    1热度

    2回答

    我正在使用+ (BOOL)setThreadPriority:(double)p;更改NSThread的优先级,但threadPriority始终为0.5。返回值setThreadPriority:是TURE。 _thread = [[NSThread alloc] initWithTarget:self selector:@selector(runThread) object:nil]; -

    -1热度

    2回答

    对于令人困惑的标题,我将此代码块运行在其自己的线程中,并且想要访问另一个类(视图控制器)中的类变量,每次它的价值改变。 为了在这里澄清我的问题是一个简单的类结构,它代表了我正在努力完成的任务。 @interface classB : NSObject { NSThread * _someThread; } + (classB*) instance; @property(ato

    9热度

    2回答

    因此,我有一个应用程序触发一系列异步事件,然后将结果写入缓冲区。的问题是,我想要的缓冲器被写入到同步(在产生了异步处理的线程) 骨架码作为这样 let Session = NSURLSession.sharedSession() let TheStack = [Structure]() //This gets called asynchronously, e.g. in threads 3,4

    0热度

    3回答

    我在我的项目中有一个错误(我已经第二次遇到),我只需在UIViewController视图的顶部添加一个视图。什么都不突出,像这样: override func viewDidAppear(animated: Bool) { super.viewDidAppear(animated) self.displayEmailNotificationsIfNeeded() } 的

    0热度

    1回答

    我明确创建了一个带NSThread类的工作线程。 NSThread *workerThread = [[NSThread alloc] initWithTarget:self selector:@selector(doWork) object:nil]; [workerThread start]; 我知道有在NSThrea

    0热度

    1回答

    我想了解NSThread是如何工作的,当应用程序去背景。我有以下代码在appdeligate: - (void)applicationDidEnterBackground:(UIApplication *)application { [self backgroundHandler]; } - (void)backgroundHandler { NSInteger co

    -1热度

    3回答

    我有一个函数,它接受一个块作为参数: typedef void (^ MyBlock)(int); -(void)doTask:(MyBlock)theBlock{ ... } 我需要上述功能在另一个线程运行,我想用- performSelector:onThread:withObject:waitUntilDone:,我当前的代码: NSThread *workerThread =

    0热度

    1回答

    我知道由NSThread创建的辅助线程的默认状态是detached,我想知道是否可以将状态更改为joinable使用NSThread的某些api而不是pthread?