简体   繁体   English

我应该如何使用JSON作为媒介来构建应用程序以将数据从服务器发送到iPhone?

[英]How should I archecture app to send data from server to iPhone using JSON as medium?

I have an iOS application that communicates with web server. 我有一个与Web服务器通信的iOS应用程序。 For simplicity, the app has only one UITableView and cells only have one UIImageView with a label. 为简单起见,该应用程序只有一个UITableView,而单元格只有一个带有标签的UIImageView。

What are the best practices when sending the text data from the server to the device? 将文本数据从服务器发送到设备时,最佳做法是什么?

I have read that we can just ecode the UIImages from the server and pass it to the device together with the other text like so: 我已经读到我们可以从服务器对UIImage进行编码,并将其与其他文本一起传递给设备,如下所示:

text: "someText"
image:"*&TFUNITGH(U*Y&^(*YG ---encodedData"

But is this the right approach to send them both together in JSON format? 但这是将两者以JSON格式一起发送的正确方法吗? Is there a better way? 有没有更好的办法? Basically what i'm asking is, how best do i architecture my app so that I don't shoot my self in the foot when the project gets much larger and more complex? 基本上,我要问的是,如何最好地构建我的应用程序,以便当项目变得更大和更复杂时,我不会陷入困境? Any advice is much appreciated thanks. 任何建议,非常感谢。

As one commenter mentioned, the best approach would be: 正如一位评论者所述,最好的方法是:

  1. Server sends URL image links 服务器发送URL图像链接
  2. App loads the images asynchronously 应用程序异步加载图像

This works well since the images are usually hosted on some image server for speed. 由于图像通常出于速度原因通常托管在某些图像服务器上,因此效果很好。

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

相关问题 如何使用json将更新的数据发送到iPhone中的服务器? - How to send the updated data using json to server in iphone? 将数据从服务器发送到iPhone应用程序 - Send data from server to iPhone app 我应该如何从json字符串中读取数据? 苹果手机 - How should I read the data from a json string? iphone iPhone如何与JSON文件一起发送大图像? 我应该将其嵌入JSON中还是单独发送? - iPhone how to send a large image along with a JSON file? Should I embed it within the JSON or send separately? 如何将数据从服务器发送到应用程序? - How do I send data from server to an app? 如何将我的应用数据从一部 iPhone 发送到另一部 - How can I send my app data from one iPhone to another 如何使用JSON-API从iPhone应用程序直接将数据插入WordPress数据库? - How to insert data directly into WordPress database from iPhone app using JSON-API? 如何将数据从iPhone发送到服务器并在站点中显示 - How to send data from iPhone to a Server and show it in the site 如何在iPhone应用程序中缓存Javascript和JSON数据? - How can I cache Javascript and JSON data in my iPhone app? 如何从iPhone将数据发送到Apple TV应用 - How to send data to apple tv app from my iphone
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM