I have an instance variable that's not declared as an optional type in Swift (it always has an initial value).
var array: Array<MyObject> = []
Later in my project I realized I should make it an optional:
var array: Array<MyObject>?
When I do this, however, it breaks all occurrences of the variable in the current code. I suddenly have to append a ?
to every time it is invoked.
Is there a way of writing variables in Swift such that its occurrences do not break when you toggle between making it optional and non-optional?