开发者

iOS communicating with OS X

I'm looking for a pointer in the right direction to get started with writing an iPhone app that sends comm开发者_如何学运维ands to OS X, for example telling OS X to sleep. I can't seem to find the relevant part of the documentation?


AFAIK, most apps have been performing this kind of communication with a client/server design, where a "server" app runs on the host OS X machine, and a "client" app on the iOS device connecting using some sort of protocol (HTTP? Bonjour?).

You won't find this in the documentation because this is a niche design pattern that few apps need (especially since documents can now be shared more easily with the new version of iOS and iTunes).


iOS doesn't support ObjC remote objects, which would be the easiest way to communicate between two OS X machines.

An alternative to the HTTP client/server approach could be making your iPhone app connect in via a remote Unix shell to the OS X machine (via ssh) and then issuing Unix or AppleScript commands to perform your system actions.


You could also set up a socket connection. I have done a app for Android, that does exactly the same for Windows computers. The app is in use in a computer store :)

For Mac, you have to use sudo command, so you need the user to type in password, on first use.

Then the server application on the Mac can send "sudo shutdown -h now" to the terminal when the server application gets a predefined byte stream on the socket input.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜