Files
SideStore/Sources/SideStoreCore/Model/Team.swift

72 lines
1.8 KiB
Swift
Raw Normal View History

//
// Team.swift
// AltStore
//
// Created by Riley Testut on 5/31/19.
// Copyright © 2019 Riley Testut. All rights reserved.
//
import CoreData
2023-03-01 00:48:36 -05:00
import Foundation
import AltSign
2023-03-01 00:48:36 -05:00
public extension ALTTeamType {
2019-06-06 14:46:23 -07:00
var localizedDescription: String {
2023-03-01 00:48:36 -05:00
switch self {
2019-06-06 14:46:23 -07:00
case .free: return NSLocalizedString("Free Developer Account", comment: "")
case .individual: return NSLocalizedString("Developer", comment: "")
2019-06-06 14:46:23 -07:00
case .organization: return NSLocalizedString("Organization", comment: "")
case .unknown: fallthrough
@unknown default: return NSLocalizedString("Unknown", comment: "")
}
}
}
2023-03-01 00:48:36 -05:00
public extension Team {
static let maximumFreeAppIDs = 10
}
@objc(Team)
2023-03-01 00:48:36 -05:00
public class Team: NSManagedObject, Fetchable {
/* Properties */
@NSManaged public var name: String
@NSManaged public var identifier: String
@NSManaged public var type: ALTTeamType
2023-03-01 00:48:36 -05:00
@NSManaged public var isActiveTeam: Bool
2023-03-01 00:48:36 -05:00
/* Relationships */
@NSManaged public private(set) var account: Account!
@NSManaged public var installedApps: Set<InstalledApp>
@NSManaged public private(set) var appIDs: Set<AppID>
2023-03-01 00:48:36 -05:00
public var altTeam: ALTTeam?
2023-03-01 00:48:36 -05:00
override private init(entity: NSEntityDescription, insertInto context: NSManagedObjectContext?) {
super.init(entity: entity, insertInto: context)
}
2023-03-01 00:48:36 -05:00
public init(_ team: ALTTeam, account: Account, context: NSManagedObjectContext) {
super.init(entity: Team.entity(), insertInto: context)
2023-03-01 00:48:36 -05:00
self.account = account
2023-03-01 00:48:36 -05:00
update(team: team)
}
2023-03-01 00:48:36 -05:00
public func update(team: ALTTeam) {
altTeam = team
name = team.name
identifier = team.identifier
type = team.type
}
}
2023-03-01 00:48:36 -05:00
public extension Team {
@nonobjc class func fetchRequest() -> NSFetchRequest<Team> {
NSFetchRequest<Team>(entityName: "Team")
}
}