バックグラウンドで実行されているwhileステートメントがあります。
- (IBAction)startButton
{
[self performSelectorInBackground:@selector(Counter) withObject:nil];
.....
}
- (void) Counter
{
while (round) {
if (condition)
{
NSString *str;
str = [NSString stringWithFormat:@"%d",counter];
[self performSelectorOnMainThread:@selector(updateLabel:) withObject:str waitUntilDone:NO];
}
}
}
- (void)updateLabel: (NSString*) str
{
[self.label setText:str];
NSLog(@"I am being updated %@",str);
}
NSlog は正しい更新された値を取得しますが、ラベルは更新されません。
私は何を間違っていますか?
アップデート:
ラベルが接続され、while ステートメントが完了すると更新されます。
また、ラベルを初期化しました。
- (void)viewDidLoad
{ [super viewDidLoad];
label.text = @"0";
}