Вопрос

I'm working on an application which contains a photo album. When a photo from an album is tapped it pops up and shows the likes and comments it got as we have in Facebook. The information of likes and comments is fetched from the server. Do I need to store this information of likes/comments fetched from server in core data or simply use arrays for it. Please suggest?

Это было полезно?

Решение

I'm not sure if I understand exactly what you mean but here is my solution:

  1. Create a class Photo which has

    1.1. photoURL as NSString

    1.2. numberOfLikes and numberOfComments as NSInteger.

    1.3. arrayLikes and arrayComments as NSArray of NSString for simplicity. If you want user to access other user's profile, you may think of create an another class User.

  2. In runtime, use an arrayPhotos to contains all the downloaded Photos.

  3. Whether you display your photos in a table or a collection view, just use indexPath.row to access each Photo in arrayPhotos and get the informations.
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top