[英]Sharing Data Between iOS devices
I would like to do data sharing(Maybe xml
or json
file) between 2 iOS devices (iPhone or iPad) and communication would be like "one to many bidirectional" bases at a time. 我想在2个iOS设备(iPhone或iPad)之间进行数据共享(也许是xml
或json
文件),并且通信一次就像是“一对多双向”基础。
With some experience and from articles , I have found below ways to do it. 通过一些经验和文章,我发现了以下实现方法。
Could anybody please suggest the best way to fulfill my requirement, which is a good way to do it? 有人可以提出建议来满足我的要求的最佳方法吗?这是一个很好的方法吗?
Since IOS 7 Multipeer Connectivity
could also be quite interesting. 由于IOS 7 Multipeer Connectivity
也可能非常有趣。
The Multipeer Connectivity framework provides support for discovering services provided by nearby iOS devices using infrastructure Wi-Fi networks, peer-to-peer Wi-Fi, and Bluetooth personal area networks and subsequently communicating with those services by sending message-based data, streaming data, and resources (such as files). Multipeer Connectivity框架支持使用基础设施Wi-Fi网络,对等Wi-Fi和蓝牙个人局域网来发现附近的iOS设备提供的服务,并随后通过发送基于消息的数据,流式数据与这些服务进行通信。以及资源(例如文件)。
Here is a nice tutorial about implementing a file sharing system using multipeer connectivity: http://www.appcoda.com/intro-ios-multipeer-connectivity-programming/ 这是一个有关使用多对等连接实现文件共享系统的很好的教程: http : //www.appcoda.com/intro-ios-multipeer-connectivity-programming/
Wi-Fi Connecting to your Personal Hotspot via Wi-Fi is the default option provided by Apple, since you have to specifically accept if you also want to enable the Bluetooth connection. Wi-Fi通过Wi-Fi连接到您的个人热点是Apple提供的默认选项,因为如果您还想启用蓝牙连接,则必须明确接受。 A Wi-Fi connection provides: Wi-Fi连接可提供:
Pros 优点
High throughput: Throughput via Wi-Fi Personal Hotspot can be of around 30 Mbps between two devices and even more. 高吞吐量:两台设备之间通过Wi-Fi个人热点的吞吐量大约为30 Mbps,甚至更高。 Faster: Connecting via Wi-Fi tends to be quite faster than connecting via Bluetooth. 更快:通过Wi-Fi连接往往比通过蓝牙连接要快得多。
Cons 缺点
Might need you to reconnect every time: Wi-Fi tends to be unstable and to turn itself off every time you put your iPhone to sleep. 每次都可能需要您重新连接:Wi-Fi趋于不稳定,每次将iPhone睡眠时,Wi-Fi都会自动关闭。 This means that you have to take out your iPhone and re-enable the Personal Hotspot if you want to connect. 这意味着如果要连接,您必须拿出iPhone并重新启用“个人热点”。 Time limit: Perhaps the biggest drawback of using a Wi-Fi Personal Hotspot with your iPhone is that in order to minimize power consumption, your iPhone only gives you a short while (90 seconds reportedly) to connect a device to it after you enable Wi-Fi Personal Hotspot. 时间限制:也许在iPhone上使用Wi-Fi个人热点的最大缺点是,为了最大程度地降低功耗,在启用Wi-Fi之后,iPhone只给了您一小段时间(据报道为90秒) -Fi个人热点。 If you take longer than that, you are forced to enable the option again. 如果花费的时间更长,则必须再次启用该选项。 More power consumption: The Wi-Fi Personal Hotspot consumes more power than its Bluetooth counterpart, which is also part of the reason it only gives you a short while to connect a device. 功耗更高:Wi-Fi个人热点比蓝牙同类产品消耗更多的功率,这也是部分时间仅能使您连接设备的原因之一。 A bit more complex: The iPhone's Wi-Fi Personal Hotspot requires you to enter a password and to configure your own security options. 稍微复杂一点:iPhone的Wi-Fi个人热点要求您输入密码并配置自己的安全性选项。
Bluetooth 蓝牙
Contrary to the Wi-Fi connection, using your Personal Hotspot via Bluetooth offers some key advantages and one huge drawback: 与Wi-Fi连接相反,通过蓝牙使用“个人热点”具有一些主要优点和一个巨大缺点:
Pros 优点
No time limit: Once you enable Bluetooth Personal Hotspot, there is no time limit for you to connect your device to your iPhone. 没有时间限制:启用Bluetooth Personal Hotspot后,将设备连接到iPhone没有时间限制。 Automatic pairing: Bluetooth remains dormant and ready to connect to your devices the moment you wake them up. 自动配对:蓝牙保持休眠状态,并在您唤醒设备后随时可以将其连接到设备。 Additionally, Bluetooth is more power-efficient than Wi-Fi. 此外,蓝牙比Wi-Fi更省电。 Security handled automatically: The security level of a Bluetooth Personal Hotspot is equivalent to Wi-Fi's WPA2, and it is all handled transparently from the moment you connect to it. 自动处理的安全性:蓝牙个人热点的安全级别与Wi-Fi的WPA2等效,并且从连接到您的那一刻起,所有这些透明地进行处理。
Cons 缺点
Very limited throughput: Without a doubt the biggest drawback of using a Bluetooth Personal Hotspot is its limited throughput, which can be of just 3 Mbps at the most, making it 10 times less than what your Wi-Fi Personal Hotspot can offer. 吞吐量非常有限:毫无疑问,使用蓝牙个人热点的最大缺点是吞吐量有限,最多只能达到3 Mbps,比您的Wi-Fi个人热点所提供的吞吐量少10倍。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.