質問

だから私はこの変数をAppDelegate.hという名前の代表に持っています:

AVAudioPlayer *introSound;

最初の負荷中に継続的に再生されます。

[introSound stop];

私がやりたいのは、別のコントローラー、FirstController.mからそれを停止することです。

私は試した

[AppDelegate.introSound stop];

しかし、それは次のように言ってエラーを投げました

エラー:予想 ':' before '。'トークン

何が原因ですか?

役に立ちましたか?

解決

コンパイラエラーを意味すると思いますか? AppDelegateは、アプリケーションの代表者であるクラスのインスタンスではなく、クラスを指します。どこからでもそれを得るには、これを行います。

AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
[appDelegate.introSound stop];

また、AppDelegateのインスタンス変数だけでなく、内省がプロパティであることを確認する必要があります。

他のヒント

この方法を使用して、シンプルで最高のビデオ/オーディオをキャッチします。

NSMutableURLRequest *request1 = [[[NSMutableURLRequest alloc] init] autorelease];
[request1 setHTTPMethod:@"GET"];
NSError *error;
NSURLResponse *response;

NSString *documentFolderPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSFileManager *fileManager1 = [NSFileManager defaultManager];
NSString *videosFolderPath = [documentFolderPath stringByAppendingPathComponent:@"videos"]; 
//NSString* videosFolderPath = [@"~/Documents/bar.mp3" stringByExpandingTildeInPath];
NSLog(@"video  path:%@",videosFolderPath);
//Check if the videos folder already exists, if not, create it!!!
BOOL isDir;
if (([fileManager1 fileExistsAtPath:videosFolderPath isDirectory:&isDir] && isDir) == FALSE) {
    //[[NSFileManager defaultManager] createDirectoryAtPath:videosFolderPath attributes:nil];
    [fileManager1 createDirectoryAtPath:videosFolderPath withIntermediateDirectories:YES attributes:nil error:nil];
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top