ARC is destroying your audio player before it gets any chance to output audio. When an audio player is about to be destroyed, it stops playing audio. Assign it to a strong property instead of a local variable, like so:
@interface MyClass : UIViewController
@property(nonatomic, strong) AVAudioPlayer *backgroundMusic;
@end
@implementation MyClass
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *musicFile = [[NSBundle mainBundle] URLForResource:@"Jaunty Gumption"
withExtension:@"mp3"];
self.backgroundMusic = [[AVAudioPlayer alloc] initWithContentsOfURL:musicFile
error:nil];
self.backgroundMusic.numberOfLoops = -1;
[self.backgroundMusic play];
}
@end
Doing this will keep the audio player alive at least as long as the view controller.