Skip to content

Fix/UserDefaults KVO#361

Merged
borut-t merged 4 commits intodevelopfrom
fix/user-defaults-kvo
Nov 18, 2025
Merged

Fix/UserDefaults KVO#361
borut-t merged 4 commits intodevelopfrom
fix/user-defaults-kvo

Conversation

@borut-t
Copy link
Copy Markdown
Collaborator

@borut-t borut-t commented Nov 14, 2025

Made a change to handle scalar types without codable.

@borut-t borut-t requested review from a team and EgzonArifi November 14, 2025 15:27
@borut-t borut-t force-pushed the fix/user-defaults-kvo branch from 09c3470 to efbbfe5 Compare November 17, 2025 10:37
@borut-t borut-t force-pushed the fix/user-defaults-kvo branch from efbbfe5 to e8e3e23 Compare November 17, 2025 10:42
public var wrappedValue: Value {
get {
// try to read as primitive type first (for @AppStorage compatibility)
if let primitiveValue = readPrimitive() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This primitive fast-path means Bool/Int/Double/Float will always return the value from UserDefaults (false/0 when the key is missing) and never fall back to defaultValue. For those types, defaultValue no longer represents “value when nothing is stored”, which is a breaking semantic change. We should probably restore a way to use defaultValue for the “missing key” case.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EgzonArifi got it - 3bfb01c

@borut-t borut-t requested a review from EgzonArifi November 17, 2025 13:44
@borut-t borut-t force-pushed the fix/user-defaults-kvo branch from 8e8b171 to 3bfb01c Compare November 17, 2025 13:46
Copy link
Copy Markdown
Member

@EgzonArifi EgzonArifi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@borut-t borut-t merged commit e8914b2 into develop Nov 18, 2025
1 of 2 checks passed
@borut-t borut-t deleted the fix/user-defaults-kvo branch November 18, 2025 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants