Created
August 30, 2020 12:53
-
-
Save agammahajan1/e7db93a3660ffca31454226085efdd01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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