Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development > iPhone SDK Development - Advanced Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 03-22-2011, 05:11 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 10
kylej is on a distinguished road
Default External Accessory help

So the app I am writing has future potential for a range of accessories. I have no problem getting one accessory connected, but I want to obtain an array of all the accessories I support so I can prompt the user for which accessory they would like to use out of the ones connected. These accessories could be bluetooth or 30-pin.
I have this code, given to me by a manufacturer, that will scan for a device with their protocol string within an array they have created. The strange thing is that they loop through this array, but they only test if an item at index 0 matches their protocol string, unless I am reading it wrong of course. Could someone take a look at the code below and explain to me why they only search for an item at index 0? Is that perhaps reserved for the dock connector?
Quote:
-(NSArray *) devicesConnected
{
NSMutableArray *devices;
EAAccessoryManager *accessoryManager = [EAAccessoryManager sharedAccessoryManager]; [accessoryManager registerForLocalNotifications];

NSArray *array = [accessoryManager connectedAccessories]; EAAccessory *accessory;

for(accessory in array)
{
if ([[accessory.protocolStrings objectAtIndex:0] isEqualToString:@"com.*******.********"])
{
if (accessory.connected == true)
{
[devices addObject:[accessory.protocolStrings objectAtIndex:0]];
}
}
}
return devices;
}
kylej is offline   Reply With Quote
Old 03-29-2011, 02:55 PM   #2 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 66
dcool is on a distinguished road
Default

I believe there is a sample code called "EADemo" in WWDC10 session. That will show you exactly what you need. List of accessory and pick from the list.

Keep in mind, with MFi agreement, you're not allow to show code to public.
dcool is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 388
19 members and 369 guests
baja_yu, benney_swet, Brandt, Domele, Droverson, Duncan C, fredidf, Free App Monster, givensur, iAppDeveloper, locombiano89, Mah6447, MasterX, Meoz, simplymuzik3, SLIC, stanny, stevenkik, Tomsky
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,646
Threads: 94,111
Posts: 402,864
Top Poster: BrianSlick (7,990)
Welcome to our newest member, locombiano89
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:58 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0