-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
37 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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
23 changes: 23 additions & 0 deletions
23
14th-team5-iOS/Core/Sources/Common/Protocol/ItemIndexable.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// ItemIndexable.swift | ||
// Core | ||
// | ||
// Created by 마경미 on 20.01.24. | ||
// | ||
|
||
import UIKit | ||
import RxDataSources | ||
|
||
public protocol ItemIndexable { | ||
associatedtype Item | ||
|
||
subscript(indexPath: IndexPath) -> Item { get set } | ||
} | ||
|
||
extension ItemIndexable { | ||
public func item(at index: IndexPath) throws -> Item { self[index] } | ||
public func items(at indexes: [IndexPath]) throws -> [Item] { try indexes.map(self.item(at:)) } | ||
} | ||
|
||
extension TableViewSectionedDataSource: ItemIndexable { } | ||
extension CollectionViewSectionedDataSource: ItemIndexable { } |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// Array+Ext.swift | ||
// Core | ||
// | ||
// Created by 마경미 on 20.01.24. | ||
// | ||
|
||
import Foundation | ||
|
||
extension Array { | ||
public init(with element: Element) { | ||
self = [element] | ||
} | ||
} |