Ios 目标-c选择器的未知类方法';游戏时间';

Ios 目标-c选择器的未知类方法';游戏时间';,ios,objective-c,avaudioplayer,Ios,Objective C,Avaudioplayer,我正在尝试使用AVAudioPlayer和playAtTime在用户设置的时间设置一个警报,当我使用此代码时[AVAudioPlayer playAtTime:dateTimeString]; 若要尝试在用户设置的时间播放,我会遇到以下错误选择器“playAtTime”没有已知的类方法。。我的代码的其余部分如下 #import "ViewController.h" @interface ViewController() { AVAudioPlayer *_myPlayer;

我正在尝试使用
AVAudioPlayer
playAtTime
在用户设置的时间设置一个警报,当我使用此代码时
[AVAudioPlayer playAtTime:dateTimeString];
若要尝试在用户设置的时间播放,我会遇到以下错误
选择器“playAtTime”没有已知的类方法。
。我的代码的其余部分如下

 #import "ViewController.h"

 @interface ViewController()
 {
      AVAudioPlayer *_myPlayer;
 }
@end

@implementation ViewController

 - (void)viewDidLoad
{
 [super viewDidLoad];
 // Do any additional setup after loading the view, typically from a nib.

NSString *path = [NSString stringWithFormat:@"%@/drum01.mp3", [[NSBundle mainBundle] resourcePath]];
NSURL *soundUrl = [NSURL fileURLWithPath:path];
_alarmPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:soundUrl error:nil];

}

-(IBAction) alarmSetButtonTapped:(id)sender {

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSString *dateTimeString = [dateFormatter stringFromDate: dateTimePicker.date ];
NSLog( @"Set button tapped : %@", dateTimeString );

[AVAudioPlayer playAtTime:dateTimeString];

[self scheduleLocalNotificationWithDate: dateTimePicker.date];

}

- (void)didReceiveMemoryWarning
{
  [super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end
和viewcontroller.h

#import <UIKit/UIKit.h>
#import <AvFoundation/AVFoundation.h>

@interface ViewController : UIViewController <AVAudioPlayerDelegate>
  {
     IBOutlet UIDatePicker *dateTimePicker;
  }


 -(IBAction) alarmSetButtonTapped:(id)sender;

 @end
#导入
#进口
@界面ViewController:UIViewController
{
IBUIDatePicker*日期时间选择器;
}
-(iAction)alarmSetButtonTapped:(id)发送方;
@结束
如何修复此错误并使用
playAtTime


感谢方法是实例方法,而不是类方法,因此必须在实例上调用它(例如,
\u alarmPlayer
)。此外,它的参数是
NSTimeInterval
,而不是字符串

在任何情况下,此方法都不能满足您的要求。它用于从一个点开始,而不是开始;该参数指示它应该开始到样本的距离。它不会安排在将来某个时间播放音频样本