0

I am making a chat room app and trying to make it so that once every hour has passed all the messages that were sent during that time gets deleted forever...

I have this so far, any help would be much appreciated!

 for message in json["Messages"].arrayValue {
                let newMessage = Message(data: message)
                if newMessage.sentTime = > 1 hour {

                    self.filterMessages(newMessage)
                }
            }
Maxi
  • 1
  • 1

1 Answers1

0

you should use NSDate to compare and then you can find difference in hours or minutes or seconds between that dates. then you can check that it is larger then one hour or not.

If you are not familiar with NSDate then refer Apple Documentation.

You can refer this answer and this QUESTION to know that how to compare two nsdate.

hope this will help :)

Community
  • 1
  • 1
Ketan Parmar
  • 27,092
  • 9
  • 50
  • 75