Send messages between iPhone & Mac

你说的曾经没有我的故事 提交于 2019-12-23 06:11:17

问题


I'm fairly novice in iPhone development, but trying to create what would seem a fairly simple application.

I want to have 1 program running on my phone/simulator that has a slider and a button, and another receiving program on the mac, such as Processing/Supercollider.

When the button is pressed i want a String such as "hello" to appear in the post window of the program on the mac, and when the slider is moved up/down for an integer, say between 0-99, to correspond with the movement on the phone. I'm assuming a WiFi connection would be essential for the sending of messages between devices.

Does anyone know how I might go about writing this - tutorials/code examples/links to get me started?

Cheers


回答1:


cocoaasyncsocket is a great wrapper around CFSocket and CFStream, that makes networking much easier. Bonjour has great documentation at developer.apple.com




回答2:


This should be done over a TCP connection which is established between your iPhone and the PC. For that to happen you need to write 2 pieces of software:

1) A client: to be installed on your iPhone

2) A server: to be installed on your PC

The server will listen to connections coming from the iPhone and once a connection is made you can send messages quite easily between the two.

This will give you a good grasp on the theory Guide to socket programming in C

Once you have that then you can find tons of Obj-C TCP examples.



来源:https://stackoverflow.com/questions/5863218/send-messages-between-iphone-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!