2010-07-05 4 views
0

여기에 지금까지 내 코드입니다 :목적 C 시간 지연

- (IBAction) startApproximiteLevel:(id)sender { 
[getBackgroundLevel startAnimation:self]; 
float sample1; 
float sample2; 
float sample3; 
float sample4; 
float sample5; 
float finalSample; 

float charlieSoundVolume = [charlieSoundLevel floatValue]; 

sample1 = charlieSoundVolume; 
sleep(1) 
sample2 = charlieSoundVolume; 
sleep(1) 
sample3 = charlieSoundVolume; 
sleep(1) 
sample4 = charlieSoundVolume; 
sleep(1) 
sample5 = charlieSoundVolume; 
sleep(1); 
finalSample = ((sample1 + sample2 + sample3 + sample4 + sample5)/5); 
self.backgroundSoundChange.floatValue = finalSample; 

[getBackgroundLevel stopAnimation:self]; 

}

하지만이 charlieSoundLevel를 업데이트 내 코드의 다른 부분을 중지합니다. 수면()없이 이것을하는 방법에 대한 아이디어? [NSObject performSelector: withObject: afterDelay:]에서

엘리야

답변

1

봐는 일정 시간 후 실행 루프의 방법을 실행합니다.

+0

예제를 보여줄 수 있습니까? – objectiveccoder001

+1

코드를 작성하기 위해 다른 사람에게 의존하지 말고 어느 시점에서 문서를 읽고 이해할 수 있어야합니다. –

+0

나는 이것을 사용하여 "시간 지연"사용에 관한 정보를 찾을 수 없다. 제발 누군가 코드를 게시 할 수 있습니다. 저를 믿으십시오, 나는 더 가난하지 않습니다 ... – objectiveccoder001