Give the following function signature in UICollectionView.
open func performBatchUpdates(_ updates: (() -> Void)?, completion: ((Bool) -> Void)? = nil)
There are some options over the Internet, that optional closures are always escaping. But, I am really not sure is that true, or this is still debatable.
- https://forums.swift.org/t/allowing-escaping-for-optional-closures-in-method-signature/27556
- https://gist.github.com/gringoireDM/1f18f3bb4e74e2d914a748d89486db56
For the above case, do we ever need [weak self], or [unowned self] in the 1st block, and 2nd black?
func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
collectionView!.performBatchUpdates({ () -> Void in
for operation: BlockOperation in self.blockOperations {
operation.start()
}
}, completion: { (finished) -> Void in
self.blockOperations.removeAll(keepingCapacity: false)
self.collectionView.reloadData()
})
}