2013-03-16 28 views
0

我想顯示我要加載的進程的倒計時,並瞭解它不允許使用ARCint轉換爲NSString。如何在NSString內顯示我的count在UILabel中顯示NSTimer計數

static int count = 0; 
count++; 

NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:(5.0) 
          target:self 
          selector:@selector(uploadData) 
          userInfo:nil 
          repeats:NO]; 

if (count <= 5) 
{ 
    ilabel.text = @"Please be patient..."; 
    NSString *counter = count; 
    counterLabel.text = counter; 
} 

回答

2

可能做到這一點,最簡單的方法是:

NSString* counter = [NSString stringWithFormat: @"%d", count]; 
+0

謝謝。我犯了一個典型的錯誤。我有這個,但是在你發佈之後,我意識到我的版本有不適宜的版本。 – Greg 2013-03-16 18:57:20

+0

不客氣。我也犯了這些錯誤。 – hvanbrug 2013-03-16 19:04:54

1
counterLabel.text = [NSString stringWithFormat:@"%d",count]; 
+0

你想通過 '計數' 中,沒有 '反'。會爲你編輯,但我不能編輯少於6個字符。 :) – hvanbrug 2013-03-16 18:46:57

+0

多數民衆贊成在罰款,:) thnks指出。 – 2013-03-16 18:48:17