Swift Errors

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

参考

你可能感兴趣的:(Swift Errors)