IceCubesApp/Packages/RSS/Sources/RSS/Models/FetchedResults<RSSFeed>+toRSSItems.swift
2024-03-14 10:59:31 +07:00

34 lines
750 B
Swift

//
// FetchedResults<RSSFeed>+toRSSItems.swift
//
//
// Created by Duong Thai on 14/3/24.
//
import SwiftUI
extension FetchedResults<RSSFeed> {
func toRSSItems() -> [RSSItem] { self.flatMap { $0.toRSSItems() } }
}
extension RSSFeed {
func toRSSItems() -> [RSSItem] { ((self.items?.allObjects as? [RSSItem]) ?? []) }
}
extension Optional<Date>: Comparable {
public static func < (lhs: Optional, rhs: Optional) -> Bool {
if let lhs, let rhs { lhs < rhs }
else { false }
}
public static func > (lhs: Optional, rhs: Optional) -> Bool {
if let lhs, let rhs { lhs > rhs }
else { false }
}
public static func == (lhs: Optional, rhs: Optional) -> Bool {
if let lhs, let rhs { lhs == rhs }
else { false }
}
}