Let me start by saying what I have works... I am not happy with it. I can simplify by doing null check and reusing a temporary variable Ideally ...
Let me start by saying what I have works... I am not happy with it. I can simplify by doing null check and reusing a temporary variable Ideally ...
Consider this enum... Given a string 'a' you can get an instance of the enum, like so: What we're trying to do is instead of returning 'nil' for ...
I have this struct and I want its init to be failable because something could go wrong with the JSON dictionary I pass: } There's no issue until I ...
I am trying to convert a Java class to Swift: If I try to initialize a Card object using the constructor with a value that isn't between 1 and 10, ...
If I declare all is fine. When using it like let a = A(), the initializer is called as expected. Now, I'd like to have the nested class X private, ...
I have the following NSDate extension initializer to create a NSDate object from a given string. But the call to self.init method force unwraps the ...
The memory allocation can fail, but I think Swift doesn't handle that cases. The code on github calls a non failable initializer EDIT: The code is ...
I’m trying to initialise a simple data model object with some JSON from SwiftyJSON. I’d like the initialiser to fail and return nil if any of the requ ...
This is from the docs, section Failable Initializers for Classes: This is described like: In the example above, the name property of the Produc ...