以编程方式将文本文件从 iPhone 粘贴到网络计算机
我想以编程方式(通过 Objective C)将文件(由我的 iPhone 应用程序创建)从我的 iPhone 粘贴到 LAN 计算机的特定文件夹。我正在使用 Wi-Fi 网络,并且我的 iPhone 和电脑位于同一网络中。
使用我的 iPhone 应用程序模拟器,我可以将文件从一个文件夹复制并粘贴到同一 MAC 中的另一个文件夹。我的目的是从预定义的计算机获取文件的最新副本,并将我的 iPhone 应用程序的文件也粘贴到该文件夹中。
I want to paste a file (created by my iPhone app) from my iPhone to a specific folder of a LAN Computer programmatically (by Objective C). I am using Wi-Fi network and my iPhone and the computer are in the same network.
Using my iPhone Application simulator, I can copy and paste files from one folder to another folder in the same MAC. My intension is to get the latest copy of the file from that predefined computer and paste the files of my iPhone App in that folder as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可以看到一个简单的选择,那就是使用 Dropbox SDK 之类的东西,并在您的计算机上部署 Dropbox 客户端。这可能不是您正在寻找的。
另一种选择是您在计算机上编写一个侦听端口的小型服务。然后,您的 iPhone 应用程序可以连接到此端口并发送文件。然后,小型服务器应用程序可以将文件写入您需要的位置。
剩下的一点是 iPhone 如何发现网络上的计算机,为此您可以使用 Bonjour 协议:http://mobileorchard.com/tutorial-networking-and-bonjour-on-iphone/ 宣传您的服务器:http://developer.apple.com/ Library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSNetService_Class/Reference/Reference.html#//apple_ref/occ/instm/NSNetService/publish
客户端 iPhone 应用程序使用
NSNetServiceBrowser
发现服务的类: http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSNetServiceBrowser_Class/Reference/Reference.htmlI can see one easy option which would be to use something like the Dropbox SDK and have a Dropbox client deployed on your computer. This isn't probably what you are looking for.
The other option is for you to write a small service on your computer which listen on a port. You iPhone app can then connect to this port and send the file. The small server app can then write the file where you need to.
The remaining point is how the iPhone can discover the computer on the network and for this you can use the Bonjour protocol: http://mobileorchard.com/tutorial-networking-and-bonjour-on-iphone/ to advertise your server: http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSNetService_Class/Reference/Reference.html#//apple_ref/occ/instm/NSNetService/publish
The client iPhone apps use the
NSNetServiceBrowser
class to discover the service: http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSNetServiceBrowser_Class/Reference/Reference.html