Skip to content

Instantly share code, notes, and snippets.

@agammahajan1
Created August 30, 2020 12:53
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save agammahajan1/e7db93a3660ffca31454226085efdd01 to your computer and use it in GitHub Desktop.
func removeVideoIfMaxNumberOfVideosReached() {
if popupVideosDict.count >= maxVideosAllowed {
// remove the least recently used video
let sortedDict = popupVideosDict.keysSortedByValue { (v1, v2) -> Bool in
v1.timeStamp < v2.timeStamp
}
guard let videoId = sortedDict.first else {
return
}
popupVideosDict.removeValue(forKey: videoId)
deleteVideo(ForVideoId: videoId)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment