2

I am trying to observe for the Darwin notification () in swift. So far I have:

 // CoreFoundation compatible types
    let cfstr: CFString = "com.apple.springboard.hasBlankedScreen" as NSString
    let notificationCenter = CFNotificationCenterGetDarwinNotifyCenter()
    let function = CFNotificationCallback(backgroundBrightnessFunction)

    //CFNotificationCenterAddObserver(notificationCenter, self, backgroundBrightnessFunction, cfstr, nil, CFNotificationSuspensionBehavior.deliverImmediately)

    CFNotificationCenterAddObserver(notificationCenter, //center
        nil, // observer
        function, // callback
        cfstr, //CFSTR("com.apple.springboard.lockcomplete"), // event name
        nil, // object
        CFNotificationSuspensionBehavior.deliverImmediately);

    //////

But the call back function field isn't allowing me to out in a normal function. How do I write a function in swift that has the CFnotificationCallback type?

Thanks,

Feras A.

FerasAS
  • 273
  • 2
  • 14
  • Possibly related? [Using CFNotificationCallback in Swift, or, @convention(c) blocks in Swift](http://stackoverflow.com/questions/40141675/using-cfnotificationcallback-in-swift-or-conventionc-blocks-in-swift) – JAL Jan 30 '17 at 12:44

0 Answers0