加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

bridgeToObjectiveC在Swift Beta 5上不可用

发布时间:2020-12-14 05:21:10 所属栏目:百科 来源:网络整理
导读:我正在编写一个在String对象上使用bridgeToObjectiveC()的应用程序.自Beta 5以来,这不再可用. 我试图这样做: self.myList.filter{($0 as MyClass).name.bridgeToObjectiveC().localizedCaseInsensitiveContainsString(searchText)} 哪个给我错误: 'String'
我正在编写一个在String对象上使用bridgeToObjectiveC()的应用程序.自Beta 5以来,这不再可用.

我试图这样做:

self.myList.filter{($0 as MyClass).name.bridgeToObjectiveC().localizedCaseInsensitiveContainsString(searchText)}

哪个给我错误:

'String' does not have a member named 'bridgeToObjectiveC'

Beta 5中的等效代码是什么?

用于转换为NSString同样的效果:
("string" as NSString).localizedCaseInsensitiveCompare("other string")

或者喜欢这个可选链接:

("string" as NSString?)?.localizedCaseInsensitiveCompare("other string")

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读