gpt4 book ai didi

swift - 参数标签 '(stringInterpolationSegment:)' 不匹配任何可用的重载

转载 作者:搜寻专家 更新时间:2023-11-01 06:11:37 25 4
gpt4 key购买 nike

更新最新的 Xcode 版本 10.2 (10E125) 后,出现此错误:

参数标签“(stringInterpolationSegment:)”不匹配任何可用的重载

还没有找到任何解决方案,有什么想法吗?

let interpolation1 = String(stringInterpolationSegment:self.addSpotAnnotation!.coordinate.latitude)
let interpolation2 = String(stringInterpolationSegment:self.addSpotAnnotation!.coordinate.longitude)
let coordinate:String = interpolation1 + "," + interpolation2

最佳答案

错误是由于changes了解字符串插值在 Swift 5 中的工作原理。

解决方案是String(stringInterpolationSegment:)替换为String(stringInterpolation:):

We do not propose preserving existing init(stringInterpolation:) or init(stringInterpolationSegment:) initializers, since they have always been documented as calls that should not be used directly. [emphasis added]

你举的例子:

coordinate:String = 
String(stringInterpolationSegment: self.addSpotAnnotation!.coordinate.latitude)
+ ","
+ String(stringInterpolationSegment: self.addSpotAnnotation!.coordinate.longitude)

可以更容易地写成:

let coordinate = "\(self.addSpotAnnotation!.coordinate.latitude),\(self.addSpotAnnotation!.coordinate.longitude)"

关于swift - 参数标签 '(stringInterpolationSegment:)' 不匹配任何可用的重载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55369435/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com