mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Add Account Sheet
The web accounts are now chunked into two columns of upto 4 accounts. Fixes #2955.
This commit is contained in:
22
Shared/Extensions/Array-Extensions.swift
Normal file
22
Shared/Extensions/Array-Extensions.swift
Normal file
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// Array-Extensions.swift
|
||||
// NetNewsWire
|
||||
//
|
||||
// Created by Stuart Breckenridge on 01/04/2021.
|
||||
// Copyright © 2021 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
extension Array {
|
||||
|
||||
/// Splits an array in to chunks of size `size`.
|
||||
/// - Note: Code from [Hacking with Swift](https://www.hackingwithswift.com/example-code/language/how-to-split-an-array-into-chunks).
|
||||
/// - Parameter size: The size of the chunk.
|
||||
/// - Returns: An array of `[Element]`s.
|
||||
func chunked(into size: Int) -> [[Element]] {
|
||||
return stride(from: 0, to: count, by: size).map {
|
||||
Array(self[$0 ..< Swift.min($0 + size, count)])
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user