Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "Attempt to set a non-property-list object to UserDefaults" #159

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/Supporting Files/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ struct Defaults {
static var requestedBluetooth: Bool

@UserDefault("permission.statusBluetooth", defaultValue: nil)
static var statusBluetooth: PermissionStatus?
static var statusBluetooth: String?

@UserDefault("permission.stateBluetoothManagerDetermined", defaultValue: false)
static var stateBluetoothManagerDetermined: Bool
Expand Down
4 changes: 2 additions & 2 deletions Source/Types/Bluetooth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extension Permission {
case .unauthorized: return .denied
case .poweredOn: return .authorized
case .resetting, .unknown:
return Defaults.statusBluetooth ?? .notDetermined
return PermissionStatus(string: Defaults.statusBluetooth) ?? .notDetermined
@unknown default: return .notDetermined
}
}
Expand All @@ -62,7 +62,7 @@ extension Permission {
extension Permission: CBPeripheralManagerDelegate {
public func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) {
Defaults.stateBluetoothManagerDetermined = true
Defaults.statusBluetooth = statusBluetooth
Defaults.statusBluetooth = statusBluetooth.rawValue

guard Defaults.requestedBluetooth else { return }

Expand Down