[ABANDONED] Mastodon iOS client.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.3 KiB

//
// AuthenticationManager.swift
// elpha-ios
//
// Created by Dwayne Harris on 8/25/18.
// Copyright © 2018 Elpha. All rights reserved.
//
import CoreData
import Foundation
import UIKit
class AuthenticationManager {
static let shared = AuthenticationManager()
var sessionCount: Int {
get {
let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
let request = NSFetchRequest<Session>(entityName: "Session")
do {
return try context.count(for: request)
} catch {
print("Error counting Sessions")
print("\(error)")
return 0
}
}
}
var selectedSession: Session? {
get {
let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
let request = NSFetchRequest<Session>(entityName: "Session")
request.predicate = NSPredicate(format: "selected = YES")
do {
let results = try context.fetch(request)
return results.first
} catch {
print("Error fetching Session")
print("\(error)")
return nil
}
}
}
private init() {}
}