参数标签'(stringInterpolationSegment :)'与任何可用的重载都不匹配 [英] Argument labels '(stringInterpolationSegment:)' do not match any available overloads

查看:145
本文介绍了参数标签'(stringInterpolationSegment :)'与任何可用的重载都不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

After updating the latest Xcode Version 10.2 (10E125), I am getting this error :

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

还找不到任何解决方案,请问有什么主意吗?

Could not find any solution yet, any idea please ?

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

推荐答案

该错误是由于

The error is due to changes to how string interpolation works in Swift 5.

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

The solution is not to replace String(stringInterpolationSegment:) with String(stringInterpolation:):

我们不建议保留现有的init(stringInterpolation :)或init(stringInterpolationSegment :)初始化程序,因为它们始终被记录为不应直接使用的调用. [加重]

您提供的示例:

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

可以更容易地写为:

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

这篇关于参数标签'(stringInterpolationSegment :)'与任何可用的重载都不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆