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

Getting Reference Time into UserDefaults error #87

Open
MohamedJaffer-24 opened this issue Feb 14, 2020 · 0 comments
Open

Getting Reference Time into UserDefaults error #87

MohamedJaffer-24 opened this issue Feb 14, 2020 · 0 comments

Comments

@MohamedJaffer-24
Copy link

MohamedJaffer-24 commented Feb 14, 2020

switch result {
case let .success(referenceTime):
BatteryStatusHandler.refTime = referenceTime
let ud = UserDefaults.standard
ud.set(referenceTime, forKey: "NTPTime")

                case let .failure(error):
                        print("Error! \(error)")
        }

In the above code, I tried to set reference Time into User Defaults , But it is a non-property list in user defaults. How can i change this to NSData or NSString to set it in userDefaults

Error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Attempt to insert non-property list object ReferenceTime(underlyingValue: FrozenNetworkTime(time: 2020-02-14 10:39:08 +0000, uptime: 611876232 ms, serverResponse: NTPResponse(packet: ntp_packet_t(client_mode: 4, version_number: 3, leap_indicator: 0, stratum: 1, poll: 3, precision: 235, root_delay: ntp_time32_t(whole: 0, fraction: 0), root_dispersion: ntp_time32_t(whole: 0, fraction: 11), reference_id: (83, 72, 77, 0), reference_time: 1581676744029 ms, originate_time: 1581680346866 ms, receive_time: 1581676748052 ms, transmit_time: 1581676748052 ms), responseTime: 1581680347149 ms, receiveTime: 1581680347149 ms), startTime: 1581680346866 ms, sampleSize: 20, host: 123.14.253.17:123) for key NTPTime'
*** First throw call stack:
(0x1acb8b180 0x1abd639f8 0x1aca953a0 0x1acbbcdc4 0x1acbbd46c 0x1acbbd1e0 0x1acbbd524 0x1aca7a3dc 0x1acb08c54 0x1acb08698 0x1aca76d64 0x1aca79d7c 0x1acbc7360 0x1ad5273b8 0x100eb7cf0 0x1016be098 0x1016be274 0x1016be30c 0x1016b7f7c 0x10176f6f4 0x101770c78 0x10177e6fc 0x1acb1cb20 0x1acb17a58 0x1acb16fb4 0x1aed1879c 0x1d9378c38 0x100f5871c 0x1ac5da8e0)
libc++abi.dylib: terminating with uncaught exception of type NSException

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant