• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: System Configuration Framework And CurrentSet notifications
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: System Configuration Framework And CurrentSet notifications


  • Subject: RE: System Configuration Framework And CurrentSet notifications
  • From: Roberto Mauro <email@hidden>
  • Date: Wed, 23 Feb 2011 11:56:19 +0100

Ok,
thank you to eskimo1 on the Apple Developer Forum I get how to setup a notification for changes on prefs.

Something like:

- (void)prefsDidChange
{
    // reread your view of the world
}

static void PrefsDidChange(
    SCPreferencesRef            prefs,
    SCPreferencesNotification     notificationType,
    void *                      info
)
{
    MyClass *   obj;

    assert(prefs != NULL);
    if (notificationType & kSCPreferencesNotificationApply) {
        obj = (MyClass *) info;
        assert([obj isKindOfClass:[MyClass class]]);

        [obj prefsDidChange];
    }
}

- (void)someMethod
{
    SCPreferencesRef        prefs;
    Boolean                 success;
    SCPreferencesContext    context = { 0, self, NULL, NULL, NULL };

    prefs = SCPreferencesCreate(NULL, CFSTR("MyAppName"), NULL);
    assert(prefs != NULL);

    success = SCPreferencesSetCallback(prefs, PrefsDidChange, &context);
    assert(success);

    success = SCPreferencesScheduleWithRunLoop(
        prefs,
        CFRunLoopGetCurrent(),
        kCFRunLoopDefaultMode
    );
    assert(success);
}


but every time prefDidChange is called when I try to get the CurrentSet from  kSCPrefCurrentSet as:

CFPropertyListRef current = SCPreferencesGetValue(prefs, kSCPrefCurrentSet);

it still returns me the previous one, like nothing is really changed, even if in the Console I can read:
CurrentSet updated to BE5263F0-0FED-4B6E-9786-E58E51F5CD1E (Automatic)

Have you any idea?

Thank you!

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Looking for help scanning entire drives
  • Next by Date: Re: Looking for help scanning entire drives
  • Previous by thread: Re: Looking for help scanning entire drives
  • Next by thread: Help with Apple Helpbooks
  • Index(es):
    • Date
    • Thread