代码:
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