-->

Can my iphone app communicate with a connected com

2020-07-16 13:32发布

问题:

Preferably, this would be a computer connected via cable, but if there's a way to do it over wifi then this would also be useful. I'm wondering if it's possible to send messages between them?

Or if i had a mac app and an iPhone app, could I communicate between them over wifi or a usb connection, rather than using a server or something?

回答1:

Connecting over WiFi is possible, cable connection however isn't possible (certainly not in the documented API) unless the phone is jailbroken.

For wifi you're just going to connect to a TCP/IP host/socket. Have a look at CocoaAsyncSocket. The computer would need to be hosting some sort of server software. This is how iTunes Remote and AirMouse work.



回答2:

There are some "permitted" (non-cracked phone) ways to send data to the iPhone from a device that's physically plugged in. There are several barcode readers - like the Linēa-pro used in US Apple stores - and magstripe readers for credit cards (e.g., the Macally Quikswipe) that can send limited amounts of data to/from the iPhone.

If your computer is a small embedded device and your data requirements are meager, it may be possible.