2 つの問題があります。
1- 次のコードを使用して、iPhone アプリにバックグラウンド ミュージックを追加しています。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
sleep(5);
//this variable can be named differently
NSString *path = [[NSBundle mainBundle] pathForResource:@"%@/background_music" ofType:@"wav"];
// the file is stored in MyApp/SharedResources folder where as delegate is placed at MyApp/
backgroundSound =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path]
error:nil];
backgroundSound.delegate = self;
[backgroundSound prepareToPlay];
[backgroundSound play];
backgroundSound.numberOfLoops = -1;
return YES;
}
@interface AppDelegate : UIResponder <UIApplicationDelegate>{
AVAudioPlayer *backgroundSound;
}
このコードを実行すると、ビルドに失敗しました。アーキテクチャ i386 の未定義シンボル:
"_OBJC_CLASS_$_AVAudioPlayer", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
私の2番目の問題..
viewController
ボタンで別の音楽をオフにする必要があるとします。どうやってやるの。例えばSettingsViewController
。
* thread #1: tid = 0x2c03, 0x90870c5a libSystem.dylib`__kill + 10, stop reason = signal SIGABRT
frame #0: 0x90870c5a libSystem.dylib`__kill + 10
frame #1: 0x90870c4c libSystem.dylib`kill$UNIX2003 + 32
frame #2: 0x909035a5 libSystem.dylib`raise + 26
frame #3: 0x909196e4 libSystem.dylib`abort + 93
frame #4: 0x90895b1b libSystem.dylib`_Unwind_Resume + 59
frame #5: 0x016c8e39 CoreFoundation`CFRunLoopRunSpecific + 345
frame #6: 0x016c8ccb CoreFoundation`CFRunLoopRunInMode + 123
frame #7: 0x0019e2a7 UIKit`-[UIApplication _run] + 576
frame #8: 0x0019fa9b UIKit`UIApplicationMain + 1175
frame #9: 0x00002a62 myApp`main + 130 at main.m:16
frame #10: 0x000029d5 myApp`start + 53
よろしくお願いします