I am new in UnsafeRawPointer
.
As I got I need to allocate unsafe memory in my extension and send pointer to my app where has to cast and release it.
Below is a sk
Thanks @MartinR, I got all answers on my questions.
We can't send an object though CFNotificationCenterPostNotification
so we need to use Darwin
and UserDefaults(suitename:)
combination.
CFNotificationCenterAddObserver
observer in the app code sending object
in UserDefaults(suitename:)
didObjectChanged
notification through CFNotificationCenterPostNotification
codedidObjectChanged
notification in CFNotificationCallback
in the app codesending object
from UserDefaults(suitename:)
Question Why do we use UnsafeRawPointer
? sample
Answer CFNotificationCenterPostNotification
is actually a C function
, and the callback is also a pure C function
. C
knows nothing about Swift types
or instance pointers
. That's why the object parameter is a UnsafeRawPointer
(the Swift
equivalent of void *
).