0
我的代碼有問題。 我午餐的線程和這個線程有一個NSTimer。 我必須記住一個可變位置,但是當我重複這個方法時,我會重新初始化這些位置,並且我失去了進度。 你能幫我嗎? 感謝線程和初始化問題
我的代碼:(這些是不是我很代碼,但也是同樣的情況我想remeber了我的號碼,但重新啓動的方法時,該程序重新初始化I)
-(void)callDectectionMove:(Movement*)tempMovement{
int i = 0;
i++;
if(i == 5)
return;
[NSTimer scheduledTimerWithTimeInterval:timeToCatch target:self selector:@selector(detectMovement) userInfo:nil repeats:NO];
}
-(int)detectPositionMovement:(float)cordX:(float)cordY:(float)cordZ:(float)sensibility{
[NSThread detachNewThreadSelector:@selector(callDectectionMove) toTarget:self withObject:tempMovement];
}
請問您可以發佈簡單的代碼嗎? – zp26 2010-07-24 12:38:41
現在你有 「int i = 0;」 將其寫爲「static int i = 0;」 - >在這種情況下,只有第一次我被初始化爲0。 – 2010-07-24 12:45:20