开发者

Data structure for imagelinks

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.


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.


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.).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜