我在项目中使用此LocationPicker,并且在构建项目时,库有一个错误说:<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ProjectFiles</ProjectView>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<StartAction>Program</StartAction>
<StartWorkingDirectory>%24%28SolutionDir%29\..\..\..\..\mydir</StartWorkingDirectory>
<StartProgram>%24%28SolutionDir%29\..\..\dir\myapplication.exe</StartProgram>
</PropertyGroup>
</Project>
,所以我打开了代码,在这里发现了以下错误代码: / p>
Value of type 'AnyObject' has no member 'hashValue'
我是swift的新手,我想也许我正在使用以上版本的swift open override func isEqual(_ object: Any?) -> Bool {
guard let object = object else { return false }
return (object as AnyObject).hashValue == hashValue
}
和5.0
来编写上述代码的另一种语法。
我尝试使用xcode建议的自动修复功能,但不起作用。
答案 0 :(得分:-1)
AnyObject不遵循哈希协议
open override func isEqual(_ object: Any?) -> Bool {
guard let object = object else { return false }
if let object = object as? Hashable {
return object.hashValue == hashValue
} else {
return false
}
}