来自Finch音频库:
- (void) play
{
[[sounds objectAtIndex:current] play];
current = (current + 1) % [sounds count]; // this line here...
}
Run Code Online (Sandbox Code Playgroud)
我试着理解它:有许多声音n,并且current每次迭代都会增加1.一旦current大于声音数n,则模数返回零.这样,它从头开始.
它是否正确?