I am currently having two issues with two different arrays:
1) In my Xcode project I have an array that contains users that is used for a tableView. Each user is part of a class called users:
class Users {
let userObjectID : String
let profilePhoto : UIImage
let fullname : String
let username : String
init(userObjectID : String, profilePhoto : UIImage, fullname : String, username : String) {
self.userObjectID = userObjectID
self.profilePhoto = profilePhoto
self.fullname = fullname
self.username = username
}
}
When I look for an object, it is possible that 1 user can have the same object twice so it appends that user twice to the array and when the array is put to the tableView, the user shows up twice. How do I take out the duplicate user based on their userObjectID? I believe I will have to sort it out after getting the data, but I am not sure how to do this.
2) The second problem is sorting another one of my arrays that contains a class by date before it is loaded to the tableView. Here is my class:
class Object {
var id: String?
var date: Date? //want to use for tableView order
var owner : String?
var ownerFullname : String?
var ownerProfilePic : UIImage?
var name: String?
}
I will like to sort the array by the 'date' that is in each 'Object' but I am not sure how to do this.
Any guidance on both or 1 of these issues will be greatly appreciated. Thank you in advance.