Мне нужно отправить распределенное уведомление из моего приложения какао в мой проект firebreath, поэтому мне нужно создать наблюдателя и селектор в моем коде firebreath. Я изменил расширение класса на «.mm», чтобы поддерживать код Objective-C. У меня уже есть код Objective-C в моем проекте Firebreath, и он работает нормально. Но когда я пытаюсь создать наблюдателя, я получаю ошибки в своем коде, и я не знаю, как их решить.
Вот мой исходный код из проекта firebreath:
//This is the selector
- (void)receiveAppConfirmationNotification:(NSNotification*)notif{
//The application is alive.
NSLog(@"The application is alive!!!!!!!!");
}
std::string MyProjectAPI::bgp(const std::string& val)
{
//Add an observer to see if the application is alive.
NSString *observedObject = @"com.test.net";
NSDistributedNotificationCenter *center = [NSDistributedNotificationCenter defaultCenter];
[center addObserver: self
selector: @selector(receiveAppConfirmationNotification:)
name: @"App Confirmation Notification"
object: observedObject];
}
Вот мои ошибки:
...firebreath/../projects/MyProject/MyProjectAPI.mm:133: ошибка: ожидается неполный идентификатор перед токеном '-'. Это строка, в которой я определил метод «receiveAppConfirmationNotification».
...firebreath/../projects/MyProject/MyProjectAPI.mm:157: ошибка: «я» не было объявлено в этой области.
Как я могу определить селектор? Как я могу добавить наблюдателя в качестве самого класса?