最新消息:20190717 VPS服务器:Vultr新加坡,WordPress主题:大前端D8,统一介绍入口:关于

[已解决]swift中代码出错:Value of type String has no member extend

iOS crifan 1765浏览 0评论

代码:

        while let ampRange = self.rangeOfString("&", range: position ..< endIndex) {

            result.extend(self[position ..< ampRange.startIndex])

            position = ampRange.startIndex

出错:

/Users/crifan/dev/dev_root/daryun/JianDao/iOS-Client/JianDao/CrifanLib.swift:853:13: Value of type ‘String’ has no member ‘extend’

如图:

Value of type ‘String’ has no member ‘extend’

Value of type String has no member extend

Swift: Extending Array, Value of type _ has no member _ – Stack Overflow

ios – Error : Value of type ‘String’ has no member ‘URLByAppendingPathComponent’ – Stack Overflow

swift  String  extend

没有找到答案

后来在:

StringExtensionHTML on CocoaPods.org

-》StringExtensionHTML/StringExtensionHTML.swift at master · adela-chang/StringExtensionHTML

看到了:

result.appendContentsOf(self[position ..< ampRange.startIndex])

才知道:swift中之前的extend,现在换成了:appendContentsOf

然后改为:

        while let ampRange = self.rangeOfString("&", range: position ..< endIndex) {

            //result.extend(self[position ..< ampRange.startIndex])

            result.appendContentsOf(self[position ..< ampRange.startIndex])

            position = ampRange.startIndex

即可。

转载请注明:在路上 » [已解决]swift中代码出错:Value of type String has no member extend

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
62 queries in 0.133 seconds, using 18.81MB memory