Tencent / QMUI_iOS

QMUI iOS——致力于提高项目 UI 开发效率的解决方案
http://qmuiteam.com/ios
Other
7.05k stars 1.37k forks source link

Swift项目中调用闭包问题 #1338

Closed KellyCoder closed 2 years ago

KellyCoder commented 2 years ago

Swift项目中调用以下闭包 QMUIThemeManagerCenter.defaultThemeManager.identifierForTrait = { (trait) -> (NSObject) in

                return "" as NSObject
            }

会包此错误 Cannot assign value of type '(UITraitCollection) -> (NSObject)' to type '((UITraitCollection) -> NSCopying & NSObjectProtocol)?' 怎么调用方式才是正确的呢?

jiasongs commented 2 years ago

错误提示很明显 返回一个 NSCopying & NSObjectProtocol) 即: QMUIThemeManagerCenter.defaultThemeManager.identifierForTrait = { (trait) -> (NSCopying & NSObjectProtocol) in return "" as NSString }

sunimp commented 2 years ago
return "" as NSString