Closed
Description
Previous ID | SR-15124 |
Radar | rdar://problem/82537716 |
Original Reporter | @Nef10 |
Type | Bug |
Environment
Swift 5.4
Additional Detail from JIRA
Votes | 0 |
Component/s | Foundation |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: 3414fbf73d52305cd8edd91052896a16
Issue Description:
import Foundation
UserDefaults.standard.set(2, forKey: "a")
print(UserDefaults.standard.integer(forKey: "a"))
print(UserDefaults.standard.string(forKey: "a") ?? "it is nil")
On Linux it outputs:
2
it is nil
On macOS:
2
2
The documentation states:
For string values, the string associated with the specified key; for number values, the string value of the number. Returns nil if the default does not exist or is not a string or number value
Which makes the macOS behaviour correct