fatal error: can't unsafeBitCast between types of different sizes (using gamekit)

最后都变了- 提交于 2019-12-06 15:42:12

The problem is that your map statement is resulting in a type of Array<String?> because playerID is a String?, which you can't cast directly to Array<String>.

If you're certain you will always have a playerID value, you could change the statement

match.players.map { $0.playerID }

to:

match.players.map { $0.playerID! }

If you're not certain of that, then you can either use the Array<String?> value with appropriate optional handling or strip out the nil values by switching from map to flatMap:

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