Sora/Sora/Utils/Extensions/UserDefaults.swift
realdoomsboygaming c85b6690da
The update we all have been waiting for (#129)
* letstry

* actual build

* eeee

* eeeee

* eeeeeeeeeee

* l

* maybe

* yes

* dwadaw

* e

* eee

* LFG

* yes

* letsdothisagain

* yes

* Persistance Added

* lfg

* Buggy Public Build

* Prevent downloading of already downloaded episodes

* Fix file size estimates maybe

* Add downloading progress in episode cell

* yes

* yes again

* yes

* Graceful degradation implementation for Episode Cells

* Fix download Size

* yay

* e

* implement download queue

* Download Quality

* Remove Package.resolved as it may differ per environment

* Restored Xcode project file from backup branch after merge

* yes

* y

* Added set color method to UserDefaults extension

* maybe

* yes

* eeee

* YES

* fix build

* maybe

* yes

* mp4shi

* yes

* Update build.yml

* maybe fix

* yes

* yes :D

* Okay les go

* LETSGO

* Update scratchpad with latest progress before upstream merge

* Delete .cursor/merge_conflicts.md

* Delete .cursor/scratchpad.md

* Fix the AI stealing my work and crediting itself...

* Bug Fixes

* Multi Download Functionality

* Delete .cursor/scratchpad.md

* Update build.yml

* Delete iosbuild.sh

* Download Sorting

* better select stuff things
2025-05-23 19:29:31 +02:00

33 lines
826 B
Swift

//
// UserDefaults.swift
// Sulfur
//
// Created by Francesco on 11/05/25.
//
import UIKit
extension UserDefaults {
func color(forKey key: String) -> UIColor? {
guard let colorData = data(forKey: key) else { return nil }
do {
return try NSKeyedUnarchiver.unarchivedObject(ofClass: UIColor.self, from: colorData)
} catch {
return nil
}
}
func set(_ color: UIColor?, forKey key: String) {
guard let color = color else {
removeObject(forKey: key)
return
}
do {
let data = try NSKeyedArchiver.archivedData(withRootObject: color, requiringSecureCoding: false)
set(data, forKey: key)
} catch {
print("Error archiving color: \(error)")
}
}
}