分配几个声音

时间:2009-09-22 12:25:45

标签: iphone memory-management memory-leaks ipod-touch

我不确定我是否编写了这段代码(点击快速触摸按钮):

#import "iEngineRoomAppDelegate.h"
#import "iEngineRoomViewController.h"
#import "SoundEffect.h"

@implementation iEngineRoomAppDelegate

@synthesize window;
@synthesize viewController;


- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    // Override point for customization after app launch    
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];
    [self setupSounds];

}

- (void)setupSounds {
    NSBundle *mainBundle = [NSBundle mainBundle];
    timbal_big_Sound = [[SoundEffect alloc] initWithContentsOfFile:[mainBundle pathForResource:@"timbal_big" ofType:@"caf"]];
    timbal_sm_Sound = [[SoundEffect alloc] initWithContentsOfFile:[mainBundle pathForResource:@"timbal_sm" ofType:@"caf"]];

}

- (IBAction)timbal_big: (id)sender {
    SoundEffect *currentSoundEffect= timbal_big_Sound;  
    [currentSoundEffect play];  
}
- (IBAction)timbal_sm: (id)sender {
    SoundEffect *currentSoundEffect= timbal_sm_Sound;
    [currentSoundEffect play];
}

- (void)dealloc {
    [timbal_big_Sound release];
    [timbal_sm_Sound release];

    [viewController release];
    [window release];
    [super dealloc];
}

@end

1 个答案:

答案 0 :(得分:0)

SoundEffect对象的内存管理是正确的,如果你的意思。