我需要的是在这个 Mac 应用程序中有一个简单的屏幕,当 iPhone 通过 WiFi 网络传输字符串时,它只打印字符串。
该字符串只是用户在 iPhone 上上下调整的滑块的字符串值。数据将发送到 Mac 应用程序,然后 Mac 应用程序将从 WiFi 网络接收该信号并简单地打印这些值。
这是一个持续的连接。我不会尝试同步一次。我正在尝试从 Mac 监听 iPhone 设备,看看当用户从 iPhone 应用程序中上下滑动 UISlider 时 iPhone 是否发送更多字符串。
如何创建客户端?我需要使用 Bonjour 之类的吗?
What I need is to have a simple screen in this Mac app that just prints a string as the iPhone is transmitting strings through the WiFi network.
This string is simply a string value from a slider being adjusted up and down by the user on the iPhone. The data will be sent to the Mac app and then the Mac app will receive this signal from the WiFi network and simply print the values.
This is a constant connection. I'm not trying to sync once. I'm trying to listen to the iPhone device from the Mac to see if the iPhone is sending any more strings as the user slides the UISlider up and down from the iPhone app.
How can I create the client side? Do I need to use Bonjour or something?
发布评论
评论(2)
在我对 href="https://stackoverflow.com/questions/3240617/cfnetwork-and-bonjour-integration-for-iphone-to-mac-integration">这个问题,我提供了一个示例应用程序的链接,有一个 Mac 组件 和一个 iPhone 1。这些组件通过 WiFi 网络相互通信,其中一个组件的标签变化会反映在另一个组件上。这是使用 Bonjour 发现和标准网络 API 完成的。
通过简单的修改,这可以用于发送您特定情况所需的持续更新。
In my answer to this question, I provide a link to a sample application that has a Mac component and an iPhone one. These components communicate between one another over a WiFi network, with changes in a label on one being reflected in the other. This is done using Bonjour discovery and the standard networking APIs.
With simple modifications, this could be used to send the continuous updates you need for your particular case.
使用 CFNetwork 框架,您可以使用 bonjour 进行发现,然后通过本机套接字处理持久连接以来回传递数据。
http://developer.apple.com /library/ios/#documentation/Networking/Conceptual/CFNetwork/Introduction/Introduction.html
这是一个很好的入门教程,适用于 iOS,但 CFNetwork 在 OS X 中也可用。
http://mobileorchard.com/tutorial-networking-and-bonjour-on -iPhone/
Use the CFNetwork framework, you can use bonjour for discovery and then handle a persistent connection through native sockets for passing data back and forth.
http://developer.apple.com/library/ios/#documentation/Networking/Conceptual/CFNetwork/Introduction/Introduction.html
Here is an excellent tutorial to get started, its for iOS but CFNetwork is available in OS X too.
http://mobileorchard.com/tutorial-networking-and-bonjour-on-iphone/