如何创建一个从iOS应用程序通过WiFi网络接收数据的小型Mac应用程序? [英] How can I create a small Mac app that receives data over the WiFi network from an iOS app?

查看:129
本文介绍了如何创建一个从iOS应用程序通过WiFi网络接收数据的小型Mac应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要的是在这个Mac应用程序中有一个简单的屏幕,只需打印一个字符串,因为iPhone正在通过WiFi网络传输字符串。

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.

此字符串是只需用户在iPhone上上下调整滑块的字符串值即可。数据将被发送到Mac应用程序,然后Mac应用程序将从WiFi网络接收此信号并只打印值。

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.

这是一个持续连接。我不想尝试同步一次。我正试图从Mac上听iPhone设备,看看当用户从iPhone应用程序上下滑动UISlider时,iPhone是否发送了更多字符串。

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.

如何创建客户端?我需要使用Bonjour吗?

How can I create the client side? Do I need to use Bonjour or something?

推荐答案

使用CFNetwork框架,您可以使用bonjour进行发现,然后处理持久性通过本机套接字连接来回传递数据。

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

这是一个很好的入门教程,适用于iOS,但CFNetwork也可以在OS X中使用。

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 /

这篇关于如何创建一个从iOS应用程序通过WiFi网络接收数据的小型Mac应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆