Bluetooth Example Code for Cocoa (Objective-C)
I'm looking for example code for setting up a connection to a bluetooth device using the Bluetooth API in Cocoa. Apple used to include this type of example code in the XCode tools package under the /Developer/Examples/Bluetooth folder, but upon downloading the latest version of XCode (3.2.1), these bluetooth examples have been removed from that directory.
There is now a readme file located at /Developer/Examples/ReadMe.rtf that explains that all example code is on the ADC website. However, it seems that the ADC website does NOT include bluetooth sample code.
I've tried googling, but I can't seem to find any good examples for how to get bluetooth going on Mac OS X with Cocoa. Can anybody help me out? I wish I had copied those examples to a backup location before updating 开发者_如何学Cto XCode 3.2.1! Curses, Apple! Why have you taken them from me?
I recently went through my backups to look at this code and have posted it in case anyone wants to look at it.
http://cs.dal.ca/~mcormier/Bluetooth.zip
Please note that if you plan on working with Bluetooth for iOS devices then you want to use the Game Kit Peer-to-Peer Connectivity API and not this code.
Let Apple know you need these by filing a bug report (enhancement request) at https://bugreport.apple.com.
You can do what I've done: download an old copy of XCode and use Pacifist to extract what you need.
This (http://www.devx.com/wireless/Article/43502/0/page/1) shows the GameKit bluetooth to connect with ipads, iphones and ipods I believe. I got the code to work and run but couldn't connect with another device whoose bluetooth was on but only my phone was running the application built with this code. So maybe both need to run it? Anyways, hope it helps a bit, I'm also researching a better tutorial where I can actually connect to bluetooth devices and not just ipad, iphone or ipods. If I write something that works, i'll make sure to blog about it here: blog.
精彩评论