If we look at what type optional , we will see that it is enum like:
enum Optional<T> { case Some(T) case None }
And it can be Some Type like Int for example or None , in which case it has the value nil .
When you do this:
var numberOfRows: Int!
you indicate directly ! that it is not an Int type, but it is an enum Optional<Int> . At the time of creation there will be Some<Int> if it is equal, but with this ! you have it enum Optional<Int> , and the next next moment it will be None . That is why you should use ! the second time you do this:
numberOfRows!
Your nomberOfRows value is of type Optional<Int> and can be Int or nil , and you need to directly indicate that it is an Int type, to do this -- action.
source share