推荐用于iPhone开发的线程层? [英] Recommended thread layer to use for iPhone development?

查看:57
本文介绍了推荐用于iPhone开发的线程层?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不熟悉Objective C和Mac开发...看来我可以在我的应用程序中使用Posix线程API.这是推荐的方法吗?还是我应该将其用于互斥体,条件变量和线程的某些Apple API?

I'm new to Objective C, and Mac development... It appears that I can use the Posix threads API in my app.. Is this the recommended way? Or is their some Apple API I should be using for mutexes, condition variables and threads instead?

我应该补充一点,我正在为iPhone开发.

I should add that I'm developing for the iPhone.

我想确切地添加我想做的事情.基本上,CoreLocation是异步的...您告诉它开始更新您,然后它只是定期对您调用update方法...

I'd like to add exactly what I'm trying to do. Basically, CoreLocation is asynchronous... You tell it to start updating you, and then it just calls an update method on you periodically...

我遇到的问题是我需要另一个线程来阻塞,直到发生更新为止...如何使主应用程序线程阻塞,直到发生至少一个CoreLocation更新为止?他们的NSConditionVariable吗? :)

The problem I have is that I need another thread to block until an update occurs... How can I make the main application thread block until at least one CoreLocation update occurs? Is their an NSConditionVariable? :)

推荐答案

我建议您显示某种类型的加载屏幕,直到您收到第一次更新,而不是通过挂起来阻止用户界面.可能看起来像这样:

Instead of blocking the user interface by making it hang, I would suggest showing some kind of loading screen until you've received your first update. The could would look something like this:

- (void)viewDidLoad {
    ...
    [myCLLocationManager beginUpdates];
    [self showLoadingIndicator];
    ....
}

- (void)locationManager:(CLLocationManager *)manager didReceiveUpdates {
    [self hideLoadingIndicator];
    // Additionally load the rest of your UI here, if you haven't already
}

不要在逐字记录这些方法上引用我,但是从本质上讲,这就是我建议解决您问题的方式.

Don't quote me on those method calls verbatim, but that's how I suggest solving your problem, in essence.

这篇关于推荐用于iPhone开发的线程层?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆