我正在使用 Xcode 4.3,我在播放声音时遇到问题......我从我在这里找到的答案下载了这个项目,但是当我用我的http://dl.dropbox.com/u/63377498/AudioText更改他的文件时.zip我什么都听不见。可能是我的模拟器的问题?我的mac设置?我不知道...这是我使用的代码:
@interface ViewController ()
@property (nonatomic, strong) AVAudioPlayer *theAudio;
@end
@implementation ViewController
@synthesize theAudio = _theAudio;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSString *soundPath =[[NSBundle mainBundle] pathForResource:@"sad" ofType:@"caf"];
NSURL *soundURL = [NSURL fileURLWithPath:soundPath];
NSError *error;
self.theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:soundURL error:&error];
}
- (IBAction)pushBell {
[self.theAudio play];
}