Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS-Extension-Demo in Swift #2

Open
ghost opened this issue Jun 18, 2015 · 0 comments
Open

iOS-Extension-Demo in Swift #2

ghost opened this issue Jun 18, 2015 · 0 comments

Comments

@ghost
Copy link

ghost commented Jun 18, 2015

Hi,
Thanks for your sharing ^^
I have an ask about your last commit : "Add change notifications based on the Darwin notification center."
In DemoManager, there is this C function in an ObjC Class :

void sharedDataChangedCallback(CFNotificationCenterRef postingCenter,
                               void * observer,
                               CFStringRef name,
                               void const * object,
                               CFDictionaryRef userInfo)
{
    // Springboard from Darwin notification center to NSNotificationCenter.
    // Note that most of the received arguments are NULL with the Darwin notification center.
    [[NSNotificationCenter defaultCenter] postNotificationName:kDemoNotesSaveByAppNotification object:[DemoNoteManager sharedManager]];
}

In my Swift class, always this same C function :

func sharedDataChangedCallback(center: CFNotificationCenterRef,
                             observer: AnyObject,
                                 name: CFString,
                               object: AnyObject,
                             userInfo: CFDictionaryRef)
{   NSNotificationCenter.defaultCenter().postNotificationName(kDemoNotesSaveByAppNotification , object: CoreDataStore.sharedInstance)
}

When I call CFNotificationCenterAddObserver() in startObservingChangeNotifications() (in DemoManager) like that :

CFNotificationCenterAddObserver(center, nil, sharedDataChangedCallback, self.observingSaveNotificationName() as CFString!, nil, CFNotificationSuspensionBehavior.DeliverImmediately)

I have got this error : error

My method sharedDataChangedCallbackin Swift isn't correct but I don't know how to solve my issue. Could you help me about that ?

Morever, you have never called "stopObservingChangeNotifications()" in DemoManager. In MastViewController, I think this code misses :

-(void) deinit {
    DemoNoteManager *sharedManager = [DemoNoteManager sharedManager];
    [sharedManager stopObservingChangeNotifications];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants