相关疑难解决方法(0)

NSOperation在iPhone上

我一直在寻找一些具体的场景,NSOperation以确定iPhone 何时是应用程序中使用的理想工具.据我所知,这是编写自己的threaded代码的包装器.我还没有看到任何使用它的Apple演示应用程序,我想知道我是否错过了一个很棒的工具而不是使用它NSThread.

这里的理想解决方案是描述用例场景NSOperation以及如何使用它来解决您的问题.

iphone multithreading cocoa-touch objective-c nsoperation

41
推荐指数
5
解决办法
4万
查看次数

初学者在iPhone上常见的多线程错误

我刚刚在我的应用程序中引入了多线程,以获得一个愚蠢的UIActivityIndi​​catorView.好吧,活动指示器工作正常 - 但现在我的应用程序有时会崩溃,有时它不会 - 在其他条件控制的情况下......我需要弄清楚这一点,但不知道从哪里开始寻找......

那么,初学者在iPhone上多线程经常会犯一些常见错误?请具体说明您的答案.谢谢你的时间.

更新:我添加了有问题的来源以供参考.

//--------------------Where the multithreading starts------------------------


-(IBAction)processEdits:(id)sender
{
        //Try to disable the UI to prevent user from launching duplicate threads
    [self.view setUserInteractionEnabled:NO];

        //Initialize indicator (delcared in .h)
    myIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(155, 230, 20, 20)];
    myIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhite;
    [self.view addSubview:myIndicator];
    [self.view bringSubviewToFront:myIndicator];
    [myIndicator startAnimating];


    //Prepare and set properties of the NEXT modal view controller to switch to
    controller = [[EndViewController alloc] initWithNibName:@"EndViewController" bundle:nil];

    controller.delegate = self;

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


}



//-----------------------------THE THREAD WORK--------------------------------


-(IBAction)threadWork:(id)sender{ …
Run Code Online (Sandbox Code Playgroud)

iphone multithreading uikit uiactivityindicatorview

8
推荐指数
2
解决办法
1万
查看次数

多线程如何在iPhone上的Objective-C中工作?

我对iPhone开发中"线程"的概念感到困惑:

  • 为什么线程必要/ 有用
  • 如何在Objective-C中使用线程?

iphone multithreading objective-c

3
推荐指数
1
解决办法
1万
查看次数