Add Array extensions
This commit is contained in:
@@ -126,9 +126,7 @@ class OpenSourceViewController: UITableViewController {
|
||||
reuseIdentifier: self.reuseIdentifier)
|
||||
}
|
||||
|
||||
if let licences = self.downloadedLicence,
|
||||
indexPath.row < licences.count {
|
||||
let licence = licences[indexPath.row]
|
||||
if let licence = self.downloadedLicence?.get(at: indexPath.row) {
|
||||
cell?.configure(licence: licence)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// Array+Extensions.swift
|
||||
// Pods
|
||||
//
|
||||
// Created by Florian Gabach on 03/03/2017.
|
||||
//
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
extension Array {
|
||||
|
||||
/// Get an index safely
|
||||
public func get(at index: Int) -> Element? {
|
||||
guard index >= 0
|
||||
&& index < count else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return self[index]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user