How do I make an array of SystemSoundID
I cannot seem to figure it out.
I can play one sound with:
- (void) initSounds {
    // Get the main bundle for the app
    CFBundleRef mainBundle;
    mainBundle = CFBundleGetMainBundle ();
    // Get the URL to the sound file to play
    soundFileURLRef  =  CFBundleCopyResourceURL (mainBundle,CFSTR ("1"),CFSTR ("wav"),NULL);
    // Create a system sound object representing the sound file
    AudioServicesCreateSystemSoundID (soundFileURLRef, &soundFileObject);
}
-(void) play {
    AudioServicesPlaySystemSound(self.soundFileObject);
}
But I want to create an array of SystemSoundID objects. When I try to do this I keep getting errors. Can anyone show me the code to create an array of soundFileObjects and how I us开发者_如何学编程e that array in AudioServicesPlaySystemSound?
SystemSoundID is an integral, non-class, type, so you'd need to use a wrapper like NSNumber to store it in Cocoa containers like NSArray:
// assuming this property:
@property (copy) NSArray *soundFileObjects;
// creating the array:
soundFileObjects = [[NSArray alloc] initWithObjects:
                     [NSNumber numberWithUnsignedLong:soundId],
                     // more ?
                     nil];
// using it, e.g.:
SystemSoundID sid = [[self.soundFileObjects objectAtIndex:0] unsignedLongValue];
AudioServicesPlaySystemSound(sid);
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论