iOS phidget library and ARC

Supporting iOS 8 and up
rwhinric
Phidgetsian
Posts: 5
Joined: Thu Jul 14, 2011 1:07 pm
Contact:

iOS phidget library and ARC

Postby rwhinric » Sun Mar 25, 2012 10:46 am

It's not required to use ARC (automatic reference counting) with the iOS phidget21 library (since you can turn it off/on on an individual file basis) but I thought I'd give it a try (in a background task). Here is what I'm doing followed by the Xcode generated conversion. Anyone see problems? Instruments shows no leaks. Sorry about the formatting.

static int gotInputChange(CPhidgetInterfaceKitHandle phid, void *context, int ind, int val)
{
dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
^{
// background processing
[(__bridge id)context performSelector: @selector(InputChange:)
withObject:[NSArray arrayWithObjects:[NSNumber numberWithInt:ind],
[NSNumber numberWithInt:val], nil]];
//
dispatch_async( dispatch_get_main_queue(),
^{
// Main UI processing using
// results of the background processing

});
});
return 0;
}


Xcode Auto-generated conversion:

static int gotOutputChange(CPhidgetInterfaceKitHandle phid, void *context,
int ind, int val)
{
@autoreleasepool
{
[(__bridge id)context performSelectorOnMainThread:
@selector(OutputChange:)
withObject:[NSArray arrayWithObjects:[NSNumber numberWithInt:ind],
[NSNumber numberWithInt:val], nil]
waitUntilDone:NO];
}
return 0;
}

boby123
Fresh meat
Posts: 1
Joined: Mon Nov 04, 2013 5:43 am
Contact:

Re: iOS phidget library and ARC

Postby boby123 » Mon Nov 04, 2013 5:56 am

It's not required to use ARC (automatic reference counting) with the iOS phidget21 library (since you can turn it off/on on an individual file basis) but I thought I'd give it a try (in a background task). Here is what I'm doing followed by the Xcode generated conversion. Anyone see problems? Instruments shows no leaks. Sorry about the formatting.
Boby


Return to “iOS”

Who is online

Users browsing this forum: No registered users and 1 guest