views:

39

answers:

1

Here is my code so far:

- (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];

}

But this will stop another part of my code from updating the charlieSoundLevel. Any idea on how to do this without the sleep()?

Elijah

+1  A: 

Look at [NSObject performSelector: withObject: afterDelay:] to launch a method on the run loop after a certain amount of time.

Graham Lee
Can you show an example?
Elijah W.
At some point you'll need to be able to read and understand the documentation, rather than rely on others to write your code for you.
Chris Hanson
I did, I can't find any info on using a "time delay" with this. PLEASE can someone post code. Believe me, I'm not a slacker...
Elijah W.
If you look at the documentation you can see the "related sample code" section.
Graham Lee