Last active
October 11, 2018 03:50
-
-
Save vialyx/75dfde49e20ed7849c2c66c56d03fa8f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TransportStorage { | |
var output: NSObject! | |
let database: Any // <----- Constant | |
var token: String? | |
init(database: Any) { | |
self.database = database | |
} | |
} | |
let storage = TransportStorage(database: UserDefaults.standard) | |
// Optional with case .none -> nil | |
storage.token?.description | |
// this triggers a runtime error | |
storage.token!.description | |
storage.token = UUID().uuidString | |
// Optional with case .some -> String | |
storage.token?.description | |
// *** Crash!!! The output in currently nil *** | |
// this triggers a runtime error | |
// storage.output.description | |
storage.output = NSObject() | |
// Output have with value. All work good | |
storage.output.description |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment