class
- NSMutableOrderedSet
A dynamic, ordered collection of unique objects.
var mSet = NSMutableOrderedSet(array: [1, 2, 3])
print(mSet)
------------------------------------------------
{(
1,
2,
3
)}
object
- selectedBackgroundView
UITableView自定义选中背景颜色
// 设置选中背景颜色
selectedBackgroundView = UIView(frame: frame)
selectedBackgroundView?.backgroundColor = UIColor.red
function
UICollectionView更新事件有四种分别是插入、删除、刷新、移动, api使用起来和UITableView类似,具体可以自己在代码中找,如果需要执行多个更新事件,可以放到performBatchUpdates中的updates闭包中作为一组动画,然后全部执行完之后通过completion调回。
collectionView.performBatchUpdates({ () -> Void in
collectionView.insertItemsAtIndexPaths(insertIndexPaths)
collectionView.moveItemAtIndexPath(currentIndexPath, toIndexPath: toIndexPath)
}, completion: { (isFinish) -> Void in
})
tips
- throttle
Throttle.swift: Returns an Observable that emits the first and the latest item emitted by the source Observable during sequential time windows of a specified duration.
在指定的时间内,只接受第一条和最新的数据。
通过设置 latest = true,可以只接受第一条数据。
let pb1 = PublishSubject<Int>()
pb1.throttle(2, scheduler: MainScheduler.instance)
.subscribe(onNext: { int in
print("element:", int)
})
.disposed(by: bag)
pb1.onNext(1)
pb1.onNext(2)
pb1.onNext(3)
pb1.onNext(4)
pb1.onNext(5)
--------------------------------------
element: 1
element: 5
- debounce
Debouncing 函数防抖 指函数调用一次之后,距离下一次调用时间是固定的,也就是说一个函数执行过一次以后,在一段时间内不能再次执行。比如,一个函数执行完了之后,100毫秒之内不能第二次执行;