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
class SampleFlowLayout: UICollectionViewLayout { | |
override func prepare() { | |
guard let collectionView = self.collectionView else { return } | |
self.itemAttributes.removeAllObjects() | |
// go through every section.. | |
for section in 0..<collectionView.numberOfSections { | |
let numberOfItems = collectionView.numberOfItems(inSection: section) |
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
data = data.map { item -> (t, CGFloat) in | |
var score: CGFloat! | |
autoreleasepool { | |
score = self.converter(item).scoreAgainst(string) | |
} | |
return (item, score) | |
} | |
.filter { return $0.1 > CGFloat(0) } | |
.sorted { return $0.1 > $1.1 } | |
.map { return $0.0 } |