<unknown>:0: error: type 'Key' constrained to non-protocol type 'String'

删除回忆录丶 提交于 2019-12-12 03:56:58

问题


Migrating to Swift 3 from 2.3 and am running into this issue. The error is traceable to a view controller.

I do not see any extensions/protocols which would require a 'Key' constrained to 'String'.

I've tried to comment out code that might be causing the error, and have had strange results - ie removing an empty viewDidLoad() made the error appear in another class.

I'll update the thread if I make progress.


回答1:


Key is a type inside a structure maybe a struct/class like Dictionary.

Use AnyHashable as Key to replace String if in Dictionary.



来源:https://stackoverflow.com/questions/42519477/unknown0-error-type-key-constrained-to-non-protocol-type-string

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