This file contains hidden or 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
extension UICollectionView { | |
///Perform batch update based on before and after arrays | |
///An array must not contain duplicate values | |
func batchUpdate<T: Equatable>(section: Int, from oldData: [T], to newData: [T], completion: ((Bool) -> Void)? = nil) { | |
performBatchUpdates({ | |
let deletions = oldData.indices.filter { !newData.contains(oldData[$0]) } | |
deleteItems(at: deletions.map { IndexPath(item: $0, section: section) }) | |
let insertions = newData.indices.filter { !oldData.contains(newData[$0]) } | |
insertItems(at: insertions.map { IndexPath(item: $0, section: section) }) |
This file contains hidden or 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
// | |
// Cardboard.swift | |
// | |
// Created by Michael Ferenduros on 27/09/2016. | |
// Copyright © 2016 Mike Ferenduros. All rights reserved. | |
// | |
import Foundation | |
This file contains hidden or 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
extension Int64 : _ObjectiveCBridgeable | |
{ | |
public init(_ number: NSNumber) | |
{ | |
self.init(number.longLongValue) | |
} | |
public func _bridgeToObjectiveC() -> NSNumber | |
{ | |
return NSNumber(longLong: self) |