Re: SystemConfiguration.framework
Re: SystemConfiguration.framework
- Subject: Re: SystemConfiguration.framework
- From: Bill Bumgarner <email@hidden>
- Date: Sat, 28 Nov 2009 17:16:09 -0800
On Nov 28, 2009, at 5:02 PM, William Squires wrote:
> SCDynamicStoreRef
> SCDynamicStoreCreate (
> CFAllocatorRef allocator,
> CFStringRef name,
> SCDynamicStoreCallBack callout,
> SCDynamicStoreContext, *context
> );
>
> Here's where my confusion begins.
Did you read the documentation for that function? It seems relatively straightforward.
What have you tried?
> 1) Would I declare this as
> a) SCDynamicStoreRef myRef;
> b) SCDynamicStore *myRef;
> c) SCDynamicStore &myRef; // Probably not, I believe only C++ defines the "&" operator this way
> d) SCDynamicStoreRef *myRef;
a) SCDynamicStoreRef, as indicated by the Ref suffix, will be a pointer to a structure that contains an SCDynamicStore:
typedef const struct __SCDynamicStore * SCDynamicStoreRef;
This kind of declaration generally indicates that the contents of whatever the SCDynamicStoreRef points to is opaque; is not something you can muck about with directly.
>
> 2) Is a CFStringRef replaceable with a literal NSString via toll-free-bridging? And exactly what does it expect this string to contain? The name of the compiled executable?
An NSString will work fine. From the header file, it is described as "A string that describes the name of the calling process or plug-in of the caller." And so does the documentation.
Lacking more specific information, try calling it with the bundle identifier of your app or plug-in.
> 3) Do I need the callback?
"The function to be called when a watched value in the dynamic store is changed. Pass NULL if no callouts are desired."
> 4) Is there an ObjC class that encapsulates this functionality?
Nope; you might file a bug if you would like one.
> 5) The documentation states that the SCDynamicStoreRef needs to be released. I assume using the free() function in the C <stdlib.h> header?
Copy/paste from the documentation:
... Note that these functions follow Core Foundation function-name conventions. A function that has "Create" or "Copy" in its name returns a reference you must release with the CFRelease function.
b.bum
_______________________________________________
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