• 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
Passing NSTextField Pointer to IOUSBInterfaceInterface182 Callback
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Passing NSTextField Pointer to IOUSBInterfaceInterface182 Callback


  • Subject: Passing NSTextField Pointer to IOUSBInterfaceInterface182 Callback
  • From: Caylan Larson <email@hidden>
  • Date: Mon, 08 Apr 2013 17:07:03 -0500

I'm doing an asynchronous read from a USB printer.  The read works correctly.  My trouble is updating a NSTextField from within the callback.

> -(IBAction)printTest:(id)sender
> {	….

>         NSLog(@"starting async read: %@", _printerOutput);
>         NSLog(@"_printerOutput pointer = %p", _printerOutput);
>
>         result = (*interface)->ReadPipeAsyncTO(interface,
>                                                1,
>                                                readBuffer,
>                                                numBytesRead,
>                                                500,
>                                                1000,
>                                                USBDeviceReadCompletionCallback,
>                                                &(_printerOutput)
>                                                );

The callback is defined as:

> void USBDeviceReadCompletionCallback(void *refCon, IOReturn result, void *messageArg)
> {
>     NSTextField	*printerOutput = (__bridge NSTextField *) messageArg;
>     NSLog(@"_printerOutput pointer = %p", printerOutput);
> }


The pointer loses its value when inside of the callback.

2013-04-08 16:36:25.348 MyUSB[8120:303] starting async read: <NSTextField: 0x10221dc60>
2013-04-08 16:36:25.348 MyUSB[8120:303] _printerOutput pointer = 0x10221dc60
2013-04-08 16:36:27.166 MyUSB[8120:303] _printerOutput pointer = 0x0

I've looked in many places trying to mimic different ways to pass in the pointer.  There can be only one correct way.  :)

Another variation on the theme:  (__bridge void *)(_printerOutput).  This doesn't work, either.

I understand that the callback is of type IOAsyncCallback1.

Other URLs of note:
	http://www.google.com/search?client=safari&rls=en&q=another+usb+notification+example&ie=UTF-8&oe=UTF-8
	http://stackoverflow.com/questions/8010382/updating-ui-from-a-c-function-in-a-thread

Thank you for reading.

Caylan

_______________________________________________

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


  • Follow-Ups:
    • Re: Passing NSTextField Pointer to IOUSBInterfaceInterface182 Callback
      • From: Jens Alfke <email@hidden>
  • Prev by Date: NSBrowser editItemAtIndexPath:withEvent:select:
  • Next by Date: Simple Vector Based Line Charts
  • Previous by thread: Re: NSBrowser editItemAtIndexPath:withEvent:select:
  • Next by thread: Re: Passing NSTextField Pointer to IOUSBInterfaceInterface182 Callback
  • Index(es):
    • Date
    • Thread