UICollectionReusableView - Missing return in a function

若如初见. 提交于 2019-11-30 11:45:48

assert() is evaluated only in the Debug configuration. When you build an archive then the code is compiled in the Release configuration (with optimizations) and the condition is simply ignored (assumed to be true). Therefore the compiler complains about the missing return value.

You can use

fatalError("Unexpected element kind")

instead. fatalError() is always evaluated and in addition marked with @noreturn (resp. return type Never in Swift 3) so that the compiler knows that it does not return to its caller.

See also Swift - fatalError with Switch Statements.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!