开发者

warning: 'AVAudioSession' may not respond to '-setActive:fooError:' [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord fooError: &fooError];开发者_运维百科
//Activate the session
[audioSession setActive:YES fooError: &fooError];

The warning i receive is

warning: 'AVAudioSession' may not respond to '-setActive:fooError:'


It looks like you your class, or a class that you're using has an instance variable called error in its header file. Try this:

 NSError *fooError = nil;
    oneAudioC = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:&fooError];
    if (fooError)
        NSLog(@"%@",[fooError localizedDescription]);

Edit: Changed if (error) to if (fooError)


The warning already tells you what the problem is: The AVAudioSession methods are called -setCategory:error: and -setActive:error:, not -setCategory:fooError: and -setActive:fooError:, respectively. You can change parameter names any way you want but not method names:

[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error: &fooError];
//Activate the session
[audioSession setActive:YES error: &fooError];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜