我是iOS开发的新手,我有简单的目标--c类"MoneyTimer.m"用于运行计时器,从那里我想用更改的计时器值更新UI标签.我想知道如何从非UI线程访问UI元素?我正在使用Xcode 4.2和故事板.
在黑莓手机中,只需获取事件锁定即可从非UI线程更新UI.
//this the code from MyTimerClass
{...
if(nsTimerUp == nil){
nsTimerUp = [NSTimer scheduledTimerWithTimeInterval: 1.0 target:self selector:@selector(countUpH) userInfo:nil repeats: YES];
...}
(void) countUpH {
sumUp = sumUp + rateInSecH;
**//from here i want to update the UI label **
...
}
Run Code Online (Sandbox Code Playgroud)