I'm working on a music app, so I can't really approve any latancy.
I'm using the beloved touchesBegan/Moved/Ended to process my touches. Everything is going well, and I managed to synthesize a tone(using AudioUnit) and to show up a glow under the finger(using GLKit), and it all works fine if there's less then 4-7 notes/touches hitting at the same time, then it goes nuts and make the app stuck.
I understood it's becuase I'm doing lots of work(with the GLKit interface and the interface I made for my synth engine) and I need a way to fix it.
My code is built around like this:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
for(UITouch *touch in touches)
{
CGPoint lePoint = [touch locationInView:self.view];
doing some calculataions for synth engine.......
actually making the sound avilable to play through the interface........
then I start to create the sprite object for the glow
attaching it to the nsarray of the shapes
//rejoycing in the awesomness of the sound
adding the touch to the active touches array
}
}
I do the exact reverse in the touchesEnded.
So in my attempts to make it work better I tried using GCD for the GLKit stuff, so that it would happen in asynchronously, It worked, but at times I got to see a glow staying on screen because it wasn't in the array when touchesEnded tried to remove it.
So that didn't work, and I'm kind of clueless, if anybody can help I'd be thankful.