Unsolved How to implement OCX functions
-
Hi
i want to insert to my code the follow function
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center
shouldPresentNotification:(NSUserNotification *)notification
{
return YES;
}
(http://cocoathings.blogspot.co.il/2013/01/introduction-to-user-notifications-in.html)
How can i do it?
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center
-
Hi
What sort of code do you mean?
It seems to be used to inform the system that Notification should be
shown.Reading this
http://stackoverflow.com/questions/22142592/mac-os-usernotificationcenter-in-qtGives idea of how is constructed.
MyClass::MyClass() { id<NSUserNotificationCenterDelegate> self = (id<NSUserNotificationCenterDelegate>)this; [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self]; } BOOL MyClass::shouldPresentNotification(NSUserNotificationCenter *center, NSUserNotification *notification) { return YES; } void MyClass::test() { NSUserNotification *userNotification = [[[NSUserNotification alloc] init] autorelease]; userNotification.title = @"Title"; userNotification.informativeText = @"Test message"; [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:userNotification]; }
-
Hi,
I can not declare in my H file follow line
BOOL MyClass::shouldPresentNotification(NSUserNotificationCenter *center, NSUserNotification *notification)
because if i add the follow line i got compilation error
#include <Foundation/NSUserNotification.h>My pro file:
QT += core gui
TARGET = untitled
TEMPLATE = app
LIBS += -framework Foundation
INCLUDEPATH +=/System/Library/Frameworks/CoreFoundation.framework/Versions/C/Headers
SOURCES += main.cpp
HEADERS += mainwindow.h
mac
{
OBJECTIVE_HEADERS +=mainwindow.h
OBJECTIVE_SOURCES +=mainwindow.mm
} -
hi
I dont have a mac to test on
does
"/System/Library/Frameworks/CoreFoundation.framework/Versions/C/Headers"
contain
Foundation
and in there
NSUserNotification.h ? -
Not sure
-
I got error - expected unqualified - id, ....
Unknown type name 'NSString'How can i fix it?
-
@borisa said:
NSString
well u must find the .h file where its defined and include it.
update:
seems to be something else than pure .h file
http://stackoverflow.com/questions/4497378/foundation-framework-no-nsstring-h-file
so might be your XCode setup or SDK. -
Hi,
Are you planning to use Objective-C++ or plain Objective-C ?