Re: Simple Bluetooth Question
Re: Simple Bluetooth Question
- Subject: Re: Simple Bluetooth Question
- From: Jacob Engstrand <email@hidden>
- Date: Thu, 26 Jul 2007 11:04:36 +0200
On 26 jul 2007, at 01.16, Patrick Walker wrote:
First, I'm a ME student, not a CS student. I've really only
started using Xcode since the beginning of the year and can write
GUI apps but they're boring and rather useless for me.
I'm just futzing around with BT for a bit and wondering why I'm not
getting any results when asking for paired devices. The result is
always nil for any of the class (+) methods. I know there is an
autorelease error but I'm not concerned about that atm. Am I using
NSArray properly?
#import <Cocoa/Cocoa.h>
#import <IOBluetooth/objc/IOBluetoothDevice.h>
int main(int argc, char *argv[])
{
NSArray * btfav = [NSArray arrayWithArray:[IOBluetoothDevice
pairedDevices]];
NSLog(@"Size of array: %i", [btfav count]);
if ([IOBluetoothDevice pairedDevices] == nil)
NSLog(@"Nothing in pairedDevices");
else
NSLog(@"Something in pairedDevices");
if ([IOBluetoothDevice favoriteDevices] == nil)
NSLog(@"Nothing in favoriteDevices");
else
NSLog(@"Something in favoriteDevices");
return 0;
}
Output:
2007-07-25 18:55:41.548 Bluetooth[2437] Size of array: 0
2007-07-25 18:55:41.549 Bluetooth[2437] Nothing in pairedDevices
2007-07-25 18:55:41.549 Bluetooth[2437] Nothing in favoriteDevices
I didn't try your code, the machine I'm on doesn't have BT on it, but
I have had success with the following:
CFArrayRef list = IOBluetoothPairedDevices();
NSArray* pairedDevices = [NSArray arrayWithArray: (NSArray*)list];
CFRelease(list);
Hope this helps.
jak
_______________________________________________
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