Use of undeclared type 'AttributedString'

百般思念 提交于 2019-11-29 10:02:51

Although undocumented in the Xcode release notes, a version 2 update to Swift evolution proposal SE-0086 Drop NS Prefix in Swift Foundation has added the "NS" prefix back to several Foundation classes which previously dropped the prefix.

The reason is as follows:

If the class is planned to have a value-type equivalent in the near future, then keep the NS prefix. Examples: NSAttributedString, NSRegularExpression, NSPredicate.

So, the Swift AttributedString type will return at some point, as a struct next time, instead of being a class.

It sounds like some of these improvements will be "a focus area for Swift 4." For now, it's necessary to revert back to using the NSAttributedString class.

If you're curious to know how many types were affected by the SE-0086 v2 update, it looks like the revision affects ~32 types which had previously dropped the NS prefix for Swift 3.

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