[英]CFNotificationCenterAddObserver No matching function for call error
我正在寫一個越獄調整。 我正在連接所有應用程序,包括基於應用商店的應用程序。 我需要編寫一個文件來捕獲一些數據。 根據這個答案 ,最好的辦法是讓所有應用程序向SpringBoard發送通知,讓SpringBoard將文件寫入/ var / mobile / application。 但我無法編譯CFNotificationCenterAddObserver。 它給出錯誤“沒有匹配函數來調用....”。 以下是代碼段。 哦,是的,我已經包含了“CoreFoundation.h”和“CFNotificationCenter.h”(不是那么愚蠢:-)
以下代碼的想法是收聽來自SpringBoard的通知並發布來自所有其他應用的通知。
有沒有人知道如何解決這個錯誤。 我看到一些github樣本%ctor但無法消化它...
void LogEvent(CFNotificationCenterRef center,
void *observer,
CFStringRef name,
const void *object,
CFDictionaryRef userInfo)
{
NSLog(@"RecordEvent");
}
%hook UIApplication
-(void)applicationDidFinishLaunching:(UIApplication*) application
{
if( [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.springboard"] )
{
CFNotificationCenterAddObserver(
CFNotificationCenterGetDistributedNotifyCenter(),
NULL,
&LogEvent,
@"RecordTouch",
NULL,
CFNotificationSuspensionBehaviorDeliverImmediately);
}
%orig;
}
%end
CFNotificationCenterAddObserver(
CFNotificationCenterGetDistributedNotifyCenter(),
NULL,
LogEvent,
(CFStringRef)@"RecordTouch",
NULL,
CFNotificationSuspensionBehaviorDeliverImmediately
);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.