ios - 如何混淆AudioSessionAddPropertyListener

标签 ios objective-c core-foundation swizzling

我的项目中有一个正在添加音频属性侦听器的库。我确实需要能够阻止它这样做,但是我没有源代码。

对于NSNotificationCenter中的addObserver方法,我之前做过麻烦。您能帮我对AudioSessionAddPropertyListener做同样的事情吗?如果尝试添加到调用中的方法与我的白名单不匹配,我想阻止它。否则,我将调用原始方法。

我不知道应该为哪个类重载load函数。我在看里面
音频h。我正在添加一些伪/真实/名称错误的代码,以便您可以看到我正在尝试执行的操作。

#import <AudioToolbox/AudioToolbox.h>
@interface AuidoClassUmm (SOMETHING)
@end

+ (void) load
{
    Method original, swizzled;
    original = class_getInstanceMethod(self, @selector(AudioSessionAddPropertyListener:selector:name:object:));
    swizzled = class_getInstanceMethod(self, @selector(swizzled_AudioSessionAddPropertyListener:selector:name:object:));

    method_exchangeImplementations(original, swizzled);
}

-(void) swizzled_AudioSessionAddPropertyListener:selector:name:object:
{
    if(//funciton object I don't like)
    {
        return;
    }
    else
    {
        // Calls the original addObserver function
        [self swizzled_AudioSessionAddPropertyListener::notificationObserver selector:notificationSelector name:notificationName object:notificationSender];
    }
}

最佳答案

AudioSessionAddPropertyListener()是C函数,而不是Objective-C方法。你不能毛毛雨。

(即使您能解决它,也几乎肯定是个坏主意。)

关于ios - 如何混淆AudioSessionAddPropertyListener,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18994513/

相关文章:

ios - iOS7中已经实现了滚动手势如何实现页面切换?

ios - 按字母顺序对NSArray进行排序,避免使用某些字符

iphone - 如何让我的 UIPickerView 显示数组的所有元素

c++ - 在 Mac 上获取系统时区的 UTC 偏移量 (C++)

objective-c - UIPickerView : Keyboard not hiding

ios - 无法使用带有 IDFA 的 Google Analytics iOS SDK 验证人口统计报告的跟踪代码

ios - Phonegap + jQuery 移动 : injecting html files from iOS app's Documents folder with jQuery Mobile

ios - HMAccessoryDe​​legates 未调用按钮操作

ios - CF_IMPLICIT_BRIDGING_ENABLED 在 xcode5 中不起作用?

iphone - 如果我从 (__bridge) 使用 CGImageSourceCreateWithData,是否需要 "CFRelease"?