mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-16 18:23:53 +01:00
[AltStoreCore] Refactors core AltStore logic into AltStoreCore framework
AltStoreCore will contain all shared AltStore code between AltStore and any app extensions. Initially, it includes all AltStore model logic.
This commit is contained in:
80
AltStoreCore/Model/Team.swift
Normal file
80
AltStoreCore/Model/Team.swift
Normal file
@@ -0,0 +1,80 @@
|
||||
//
|
||||
// Team.swift
|
||||
// AltStore
|
||||
//
|
||||
// Created by Riley Testut on 5/31/19.
|
||||
// Copyright © 2019 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
import AltSign
|
||||
|
||||
public extension ALTTeamType
|
||||
{
|
||||
var localizedDescription: String {
|
||||
switch self
|
||||
{
|
||||
case .free: return NSLocalizedString("Free Developer Account", comment: "")
|
||||
case .individual: return NSLocalizedString("Developer", comment: "")
|
||||
case .organization: return NSLocalizedString("Organization", comment: "")
|
||||
case .unknown: fallthrough
|
||||
@unknown default: return NSLocalizedString("Unknown", comment: "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public extension Team
|
||||
{
|
||||
static let maximumFreeAppIDs = 10
|
||||
}
|
||||
|
||||
@objc(Team)
|
||||
public class Team: NSManagedObject, Fetchable
|
||||
{
|
||||
/* Properties */
|
||||
@NSManaged public var name: String
|
||||
@NSManaged public var identifier: String
|
||||
@NSManaged public var type: ALTTeamType
|
||||
|
||||
@NSManaged public var isActiveTeam: Bool
|
||||
|
||||
/* Relationships */
|
||||
@NSManaged public private(set) var account: Account!
|
||||
@NSManaged public var installedApps: Set<InstalledApp>
|
||||
@NSManaged public private(set) var appIDs: Set<AppID>
|
||||
|
||||
public var altTeam: ALTTeam?
|
||||
|
||||
private override init(entity: NSEntityDescription, insertInto context: NSManagedObjectContext?)
|
||||
{
|
||||
super.init(entity: entity, insertInto: context)
|
||||
}
|
||||
|
||||
public init(_ team: ALTTeam, account: Account, context: NSManagedObjectContext)
|
||||
{
|
||||
super.init(entity: Team.entity(), insertInto: context)
|
||||
|
||||
self.account = account
|
||||
|
||||
self.update(team: team)
|
||||
}
|
||||
|
||||
public func update(team: ALTTeam)
|
||||
{
|
||||
self.altTeam = team
|
||||
|
||||
self.name = team.name
|
||||
self.identifier = team.identifier
|
||||
self.type = team.type
|
||||
}
|
||||
}
|
||||
|
||||
public extension Team
|
||||
{
|
||||
@nonobjc class func fetchRequest() -> NSFetchRequest<Team>
|
||||
{
|
||||
return NSFetchRequest<Team>(entityName: "Team")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user