• 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
IOServiceAddMatchingNotification
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

IOServiceAddMatchingNotification


  • Subject: IOServiceAddMatchingNotification
  • From: Greg Hoover <email@hidden>
  • Date: Tue, 22 Jan 2008 09:53:25 -0700

I'm using the following code to add a notification callback for HID devices. It works the first time I plug in the USB device (and sometimes the 2nd time), but typically only the first plug in is ever registered. My understanding is that the notification is persistent and shouldn't need to be recreated, no?

Thanks in advance.

+ (void)addHIDDeviceAddedNotificationCallback: (IOServiceMatchingCallback)notificationCallback withContext:(void *)context {
NSMutableDictionary *matchingDict;
kern_return_t result;
io_iterator_t addedIterator;

if (!notifyPort)
notifyPort = IONotificationPortCreate(kIOMasterPortDefault);
CFRunLoopAddSource(CFRunLoopGetCurrent(),
IONotificationPortGetRunLoopSource(notifyPort),
kCFRunLoopDefaultMode);


matchingDict = (NSMutableDictionary *)IOServiceMatching(kIOHIDDeviceKey);
if (!matchingDict)
return;


    result = IOServiceAddMatchingNotification(notifyPort,
											  kIOFirstMatchNotification,
											  (CFMutableDictionaryRef)matchingDict,
											  notificationCallback,
											  context,
											  &addedIterator);

	// have to call to arm the notification callback
	while (IOIteratorNext(addedIterator));
}
_______________________________________________

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: Understanding the inner workings: getting to know how functions are called
  • Next by Date: Re: Understanding the inner workings: getting to know how functions are called
  • Previous by thread: Re: Understanding the inner workings: getting to know how functions are called
  • Next by thread: NSArrayController & NSTreeController default sort order
  • Index(es):
    • Date
    • Thread