可可蓝牙示例代码(Objective-C)

时间:2022-09-07 20:08:43

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.

我正在寻找使用Cocoa中的蓝牙API建立与蓝牙设备连接的示例代码。 Apple曾经在/ Developer / Examples / Bluetooth文件夹下的XCode工具包中包含这种类型的示例代码,但是在下载最新版本的XCode(3.2.1)时,这些蓝牙示例已从该目录中删除。

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.

现在有一个位于/Developer/Examples/ReadMe.rtf的自述文件,它解释了所有示例代码都在ADC网站上。但是,似乎ADC网站不包含蓝牙示例代码。

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 to XCode 3.2.1! Curses, Apple! Why have you taken them from me?

我试过谷歌搜索,但我似乎找不到任何关于如何使用Cocoa在Mac OS X上运行蓝牙的好例子。有人可以帮帮我吗?我希望在更新到XCode 3.2.1之前,我已将这些示例复制到备份位置!诅咒,Apple!你为什么要把它们从我这里拿走?

4 个解决方案

#1


2  

You can do what I've done: download an old copy of XCode and use Pacifist to extract what you need.

你可以做我已经完成的事情:下载旧版的XCode并使用Pacifist来提取你需要的东西。

#2


37  

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.

请注意,如果您打算使用蓝牙适用于iOS设备,那么您希望使用Game Kit对等连接API而不是此代码。

#3


4  

Let Apple know you need these by filing a bug report (enhancement request) at https://bugreport.apple.com.

通过在https://bugreport.apple.com上提交错误报告(增强请求),让Apple知道您需要这些。

#4


0  

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.

这个(http://www.devx.com/wireless/Article/43502/0/page/1)显示GameKit蓝牙与我相信的ipads,iphone和ipod连接。我得到了代码工作和运行,但无法连接其他设备蓝牙已启用但只有我的手机正在运行使用此代码构建的应用程序。那么也许两者都需要运行它?无论如何,希望它有所帮助,我也在研究一个更好的教程,我可以实际连接到蓝牙设备,而不仅仅是ipad,iphone或ipods。如果我写一些有用的东西,我会确保在这里写博客:博客。

#1


2  

You can do what I've done: download an old copy of XCode and use Pacifist to extract what you need.

你可以做我已经完成的事情:下载旧版的XCode并使用Pacifist来提取你需要的东西。

#2


37  

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.

请注意,如果您打算使用蓝牙适用于iOS设备,那么您希望使用Game Kit对等连接API而不是此代码。

#3


4  

Let Apple know you need these by filing a bug report (enhancement request) at https://bugreport.apple.com.

通过在https://bugreport.apple.com上提交错误报告(增强请求),让Apple知道您需要这些。

#4


0  

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.

这个(http://www.devx.com/wireless/Article/43502/0/page/1)显示GameKit蓝牙与我相信的ipads,iphone和ipod连接。我得到了代码工作和运行,但无法连接其他设备蓝牙已启用但只有我的手机正在运行使用此代码构建的应用程序。那么也许两者都需要运行它?无论如何,希望它有所帮助,我也在研究一个更好的教程,我可以实际连接到蓝牙设备,而不仅仅是ipad,iphone或ipods。如果我写一些有用的东西,我会确保在这里写博客:博客。