Page 1 of 1

iOS phidget library and ARC

Posted: Sun Mar 25, 2012 10:46 am
by rwhinric
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;
}

Re: iOS phidget library and ARC

Posted: Mon Nov 04, 2013 5:56 am
by boby123
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.