gpt4 book ai didi

ios - 预期标识符或 "("Objective C

转载 作者:行者123 更新时间:2023-11-28 20:21:19 25 4
gpt4 key购买 nike

我对 xcode 非常陌生,我正在为一个学校项目制作一个应用程序。我正在研究背景音乐代码以在同一按钮上播放/暂停(找到代码但对其进行了一些修改)。我已经能够清除其他错误,但我不知道该怎么做......预期标识符或“(”

@implementation settingscontroller2

-(void) btnAction:(UIButton*)button{
button.selected = !button.selected;}

{ //expected Identifier or "("


if (button.selected){

// Play
NSString *path = [[NSBundle mainBundle] pathForResource:@"app" ofType:@"mp3"];
theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
theAudio.delegate = self;
theAudio.numberOfLoops = -1;
[theAudio play];
}

else (!button.selected){

// Pause
[theAudio pause];
return.nil
}
}

最佳答案

一旦检查这个,

-(void) btnAction:(UIButton*)button{
button.selected = !button.selected;


if (button.selected){

// Play
NSString *path = [[NSBundle mainBundle] pathForResource:@"app" ofType:@"mp3"];
theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
theAudio.delegate = self;
theAudio.numberOfLoops = -1;
[theAudio play];
}

else if(!button.selected){//here also one problem in your code.

// Pause
[theAudio pause];
//return.nil
}
}

关于ios - 预期标识符或 "("Objective C,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15811340/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com