JGMethodSwizzler
JGMethodSwizzler copied to clipboard
EXC_BAD_ACCESS when swizzling AVAudioSession setCategory:withOptions:error:
Hi,
I'm trying to swizzle AVAudioSession's - (BOOL)setCategory:(NSString )category withOptions: (AVAudioSessionCategoryOptions)options error:(NSError *)outError method. Problem is that each time someone try to set category I get EXC_BAD_ACCESS. I assume problem is with this NSError ** but I'm unclear how to modify implementation then. Do you have some suggestion?
This is what I try to do:
[AVAudioSession swizzleInstanceMethod:@selector(setCategory:withOptions:error:)
withReplacement:JGMethodReplacementProviderBlock {
//return a replacement block
return JGMethodReplacement(BOOL, AVAudioSession *, NSString *category, AVAudioSessionCategoryOptions options, NSError **error) {
// We want to use AVAudioSessionCategoryPlayback always.
BOOL orig = JGOriginalImplementation(BOOL, AVAudioSessionCategoryPlayback, options, error);
//return the modified value
return orig;
};
}];
Yes, NSError ** is probably the culprit, where exactly is the exception thrown?
It's just EXC_BAD_ACCESS unfortunately.
+1