XIBLoader.swift
961 Bytes
//
// XIBLoader.swift
// SwiftWarplyFramework
//
// Created for SPM XIB loading support
//
import UIKit
public struct XIBLoader {
/// Safe registration of table view cells with XIB
public static func registerTableViewCell<T: UITableViewCell>(
_ tableView: UITableView,
cellClass: T.Type,
nibName: String,
identifier: String
) {
let nib = UINib(nibName: nibName, bundle: Bundle.frameworkBundle)
tableView.register(nib, forCellReuseIdentifier: identifier)
}
/// Safe registration of collection view cells with XIB
public static func registerCollectionViewCell<T: UICollectionViewCell>(
_ collectionView: UICollectionView,
cellClass: T.Type,
nibName: String,
identifier: String
) {
let nib = UINib(nibName: nibName, bundle: Bundle.frameworkBundle)
collectionView.register(nib, forCellWithReuseIdentifier: identifier)
}
}