Xcode 8中没有'advancedBy' [英] 'advancedBy' is unavailable in Xcode 8

查看:389
本文介绍了Xcode 8中没有'advancedBy'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我一直在使用XCode 8并在线使用

Currently, I've been using XCode 8 and on the line

let range = key.startIndex...key.startIndex.advancedBy(0)

我得到了错误:

错误:"advancedBy"不可用:要使索引前进n个步骤,请在生成索引的CharacterView实例上调用"index(_:offsetBy :)".

error: 'advancedBy' is unavailable: To advance an index by n steps call 'index(_:offsetBy:)' on the CharacterView instance that produced the index.

我该如何解决?

以下是错误的屏幕截图:

A screenshot of the error is below:

推荐答案

advancedBy(_:)在Swift v3中已被弃用,并由index(_:offsetBy:)代替.有关更多信息,请参阅Apple的迁移指南.

advancedBy(_:) has been deprecated in Swift v3 and replaced by index(_:offsetBy:). Refer to Apple's migration guide for more info.

错误的解决方法:

let range = key.startIndex...key.index(key.startIndex, offsetBy: 0)

这篇关于Xcode 8中没有'advancedBy'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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