图像链接的数据结构

发布于 2024-12-03 04:32:36 字数 612 浏览 2 评论 0原文

我正在开发一个住房应用程序,其中包含许多房屋,每个房屋都有属性。这些属性当前列在字典中,例如:House 0 {key: string, key: string} 等。

我目前正处于要添加一些必须下载的图像的位置并显示。我已经编写了异步图像加载器类。我只是想知道如何构建图像链接,我会是第一个一头扎进这样的事情并花两天时间调试蹩脚解决方案的人。

我考虑过在当前 House 0 字典中添加另一个名为 images 的字典,然后循环遍历它。但我很想听到更好(更简单)的解决方案。

每个房子都可以有任意数量的图像。

编辑:

我希望我不会让任何人哭泣或谋杀我...但我是这样做的:

Imagesimage.jpg,image2.jpg,image3.jpg

NSArray *ar = [[dict objectForKey@"images"] ComponentsSeparatedByString:@","];

=D

别杀我。

I'm developing a housing app with a number of houses which each have attributes. Those attributes are currently listed in a dictionary like: House 0 {key: string, key: string} etc.

I'm currently at the point where i want to add some images, which have to be downloaded and displayed. I already wrote the async image loader class. Im just wondering about how to structure the image links, and I would be the one to dive head first into something like this and spend two days debugging a crappy solution.

I thought about adding another dictionary named images in the current House 0 dict, and then looping through it. But I would love to hear better (easier) solutions.

Every house can have any number of images.

Edit:

I hope im not going to make anybody cry or murder me... But I did it like this:

<key>Images</key>
<string>image.jpg,image2.jpg,image3.jpg</string>

NSArray *ar = [[dict objectForKey@"images"] componentsSeparatedByString:@","];

=D

Dont kill me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

长不大的小祸害 2024-12-10 04:32:36

首先将字典重构为一个类,并在必要时添加归档。从长远来看,类将使代码更简单、更不易脆弱。

如果图像非常小,将它们保存在类中可能没问题,但最好将它们保存为具有类中文件名的文件。如果可能存在图像名称冲突,请创建图像名称的 UUID。

如果数据和图像需要持久化,还要考虑核心数据。

First refactor the dictionary to a class and add archiving if necessary. In the long term a class will make the code simpler and less fragile.

If the images are really small saving them in a class may be OK but it is probably better to save them as files with the file names in the class. If there is a possible image name conflict create a UUID of the image name.

Also consider Core Data if the data and images need to persist.

潦草背影 2024-12-10 04:32:36

就我个人而言,我会将所有图像存储在一个数据存储中。

我将有一个对象数组 - 每个对象都有(一个图像链接)和一个父母 ID 数组 - 因此一个图像可以在多个房屋上使用 - (例如平面图不可用图像”或房地产供应商徽标图像等.)。

Personally I would have all images in a single data store.

I would have an array of objects - each object would have (an image link) and an array of parents IDs - so an image can be used on multiple houses - (e.g. a floorplan not available image" or a real estate vendor logo image etc.).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文