I’m trying to return nil in my failable initializer but keep getting the error “All stored properties of a class instance must be initialized before returning nil from an initializer". Why?? Isn’t the whole point of failable initializers being able to return nil and stop initialization?
Asked
Active
Viewed 334 times
1 Answers
3
Apparently it’s a bug that’ll be fixed as of Swift 2.2 https://stackoverflow.com/a/26497229/5792198
In the meantime, you can initialize all the properties with dummy data and set a flag. At the end of all the init code check the flag and return nil.

Community
- 1
- 1

nazmul idris
- 432
- 6
- 17