fatal error: unexpectedly found nil while unwrapping an Optional value
It means your variable is set to nil, but your code is expecting it to not be nil.
什么叫"your code is expecting it to not be nil"呢?來看個例子:
var name : String?
name = nil
name!.uppercaseString//fatal error: unexpectedly found nil while unwrapping an Optional value
Initializer requirement 'XXXX' can only be satisfied by a required initializer in the definition of non-final class 'XXXX'
意思就是你聲明的'XXXX'這個構造器要么加上required關鍵字,要么把你的類改成final class。
為什么呢?
出現這種情況,一般是在自定義的'XXXX'構造器由于某種原因必須在子類中重寫,在子類中重寫的構造器必須加required關鍵字。當然如果是final class也就不用操這個心了,因為壓根不會有子類。
關于swift構造器可以參考Swift initializer