2011-04-14 103 views
0

我有一個應用程序,當搖動開始時啓動計時器,並在搖動結束時停止。我需要修改這個。我需要搖動它4次,每次搖動後,必須將數值推入數組中。所以最後,在4次搖動之後,4個計時器值必須保存到一個單獨的數組中。這可以做到嗎?我試圖弄清楚,但有點卡住了。晃動應用程序,iPhone

Anu類的幫助將不勝感激。 在此先感謝

回答

1
-(void) shakeEnded { 
    NSTimeInterval time = ... // get the time interval like in your first app 

    // add the time to a NSMutableArray 
    [self.timerArray addObject:[NSNumber numberWithDouble:time]]; 

    if ([self.timerArray count] == 4) { 
    // do something 
    } 

}