Products for USB Sensing and Control
It is currently Sun May 19, 2013 4:32 pm

All times are UTC - 7 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Sun Mar 25, 2012 10:46 am 
Offline
Phidgetsian

Joined: Thu Jul 14, 2011 1:07 pm
Posts: 5
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;
}


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 7 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group