1

したがって、AppDelegate.hという名前のデリゲートにこの変数があります。

AVAudioPlayer *introSound;

最初のロード中は継続的に再生されます。

[introSound stop];

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

私は試した

[AppDelegate.introSound stop];

しかし、それは次のようなエラーをスローしました:

エラー:「。」の前に「:」が必要です。トークン

これを引き起こしているのは何ですか?

4

2 に答える 2

2

コンパイラエラーのことだと思いますか?AppDelegateは、アプリケーションデリゲートであるクラスのインスタンスではなく、クラスを参照します。どこからでもそれを取得するには、次のようにします。

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

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

于 2010-09-18T13:18:41.313 に答える
1

この方法を使用して、ビデオ/オーディオをシンプルかつベストにキャッチします。これを行う

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];
}
于 2011-07-07T13:15:34.307 に答える