Ios 类型';键';限制为非协议类型';字符串';
以下文件包含以下错误:Ios 类型';键';限制为非协议类型';字符串';,ios,xcode,amazon-web-services,swift3,compiler-errors,Ios,Xcode,Amazon Web Services,Swift3,Compiler Errors,以下文件包含以下错误: Type 'Key' constrained to non-protocol type 'String' 没有任何行号 // // UserProfile+Util.swift // MySampleApp // // Modified on 05/06/2016. // // import AWSMobileHubHelper extension UserProfile { class func getDeviceArn() -> Strin
Type 'Key' constrained to non-protocol type 'String'
没有任何行号
//
// UserProfile+Util.swift
// MySampleApp
//
// Modified on 05/06/2016.
//
//
import AWSMobileHubHelper
extension UserProfile {
class func getDeviceArn() -> String? {
let pushManager: AWSPushManager = AWSPushManager.defaultPushManager()
if let _endpointARN = pushManager.endpointARN {
// pushManager.enabled = true
return _endpointARN
}else{
pushManager.registerForPushNotifications()
}
return nil
}
}
据我所知,当扩展名与“键”一起使用时,会发生此错误。
我不会用密钥扩展类。这几天我都快疯了
我知道以下问题,但它无法解决我的问题:您是否尝试将扩展设置为public,和/或将func声明为public@objc类func getDeviceArn()->String?@TheBasicMind使用“公共扩展用户配置文件{”将给出以下错误:“内部类的扩展不能声明为公共”。我也尝试了“objc类func getDeviceArn()”,但没有任何区别。仍然是相同的错误。