因此,我在我的代表中有这个变量,名为appdelegate.h:

AVAudioPlayer *introSound;

它在第一次负载期间连续播放。

[introSound stop];

我要做的是从单独的控制器FirstController.m停止它。

我试过了

[AppDelegate.introSound stop];

但这引发了一个错误,说:

错误:预期':'之前'。令牌

是什么原因造成的?

有帮助吗?

解决方案

我认为您的意思是编译器错误? 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