iOS13.1 AVAudioPlayer目标-c错误:
Thread 1: EXC_BAD_ACCESS (code=1, address=0x48)
AVAudioPlayer + Extension.h文件:
@interface AVAudioPlayer (Extension)
- (instancetype)initWithFilepath:(NSString*)filepath
delegate:(id<AVAudioPlayerDelegate>)delegate;
AVAudioPlayer + Extension.m文件:
#import "AVAudioPlayer+Extension.h"
@implementation AVAudioPlayer (Extension)
@implementation AVAudioPlayer (Extension)
- (instancetype)initWithFilepath:(NSString*)filepath
delegate:(id<AVAudioPlayerDelegate>)delegate {
NSError *error;
NSURL *url = [NSURL fileURLWithPath:filepath];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:url
error:&error];
if (error != nil) {
NSLog(@"AVAudioPlayer init failed %@", [error localizedDescription]);
return nil;
}
player.currentTime = 0;
player.delegate = delegate;
return player;
}