2022-04-18 15:25:27 -07:00
|
|
|
//
|
|
|
|
|
// ManagedPatron.swift
|
|
|
|
|
// AltStoreCore
|
|
|
|
|
//
|
|
|
|
|
// Created by Riley Testut on 4/18/22.
|
|
|
|
|
// Copyright © 2022 Riley Testut. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import CoreData
|
|
|
|
|
|
|
|
|
|
@objc(ManagedPatron)
|
2025-02-08 04:45:22 +05:30
|
|
|
public class ManagedPatron: BaseEntity
|
2022-04-18 15:25:27 -07:00
|
|
|
{
|
|
|
|
|
@NSManaged public var name: String
|
|
|
|
|
@NSManaged public var identifier: String
|
|
|
|
|
|
|
|
|
|
private override init(entity: NSEntityDescription, insertInto context: NSManagedObjectContext?)
|
|
|
|
|
{
|
|
|
|
|
super.init(entity: entity, insertInto: context)
|
|
|
|
|
}
|
2025-02-08 04:45:22 +05:30
|
|
|
|
2023-11-15 14:13:58 -06:00
|
|
|
public init?(patron: PatreonAPI.Patron, context: NSManagedObjectContext)
|
2022-04-18 15:25:27 -07:00
|
|
|
{
|
2023-03-28 14:37:47 -05:00
|
|
|
// Only cache Patrons with non-nil names.
|
|
|
|
|
guard let name = patron.name else { return nil }
|
|
|
|
|
|
2022-04-18 15:25:27 -07:00
|
|
|
super.init(entity: ManagedPatron.entity(), insertInto: context)
|
|
|
|
|
|
2023-03-28 14:37:47 -05:00
|
|
|
self.name = name
|
2022-04-18 15:25:27 -07:00
|
|
|
self.identifier = patron.identifier
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public extension ManagedPatron
|
|
|
|
|
{
|
|
|
|
|
@nonobjc class func fetchRequest() -> NSFetchRequest<ManagedPatron>
|
|
|
|
|
{
|
|
|
|
|
return NSFetchRequest<ManagedPatron>(entityName: "Patron")
|
|
|
|
|
}
|
|
|
|
|
}
|