简体   繁体   English

如何在Swift中的Apple Watch中解析服务?

[英]How to parse a service in Apple Watch in Swift?

I am working on Swift and I am new to Apple Watch Programming. 我正在开发Swift,并且是Apple Watch编程的新手。 I am making a demo app in iOS ie displaying images on feed. 我正在iOS中制作一个演示应用程序,即在feed上显示图像。 To display the images, I have to parse a service. 要显示图像,我必须解析服务。

I know how to implement it for iPhone, but I don't understand how to implement it for Apple Watch, and even I don't know that it is possible on Apple Watch or not??? 我知道如何在iPhone上实现它,但我不知道如何在Apple Watch上实现它,甚至我也不知道在Apple Watch上是否可以实现???

If it is not possible then how should I show the data from a service in Apple Watch?? 如果不可能,那么我应该如何显示Apple Watch中服务的数据?

Is there any other way to display the data in Apple Watch? 还有其他方法可以在Apple Watch中显示数据吗?

Can any one explain me about this clearly, please... 有人可以清楚地向我解释一下吗?

Thanks in advance. 提前致谢。

To consume web services on the Apple Watch you will need to use the NSURLSession API. 要在Apple Watch上使用Web服务,您将需要使用NSURLSession API。 You can also use an easy to use, popular framework called AFNetworking . 您还可以使用一个易于使用的流行框架AFNetworking This will make the requests and parse the data for you 这将发出请求并为您解析数据

I can't really explain why Alamofire is returning this error. 我无法真正解释为什么Alamofire返回此错误。 It did the same for me. 对我来说也一样。 But it was better, since the WatchOS guidelines say that you can't do long operation on the watch since it's life could be short. 但这是更好的选择,因为WatchOS指南说您不能在手表上进行长时间操作,因为它的寿命可能很短。

I built a bridge around WatchConnectivity where I send message and I reply with the response asynchronously. 我在WatchConnectivity周围WatchConnectivity了一座桥梁,在其中发送消息,然后异步答复响应。 The only difference is that you need the app on the iPhone is running (not terminated, essentially) 唯一的区别是您需要iPhone上的应用程序正在运行(本质上未终止)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM