Ios 无法转换类型为';字符串';到预期的参数类型';String.Element';(又名字符)错误 let str=“TestTest2Hello,playgroundTest” str.split(分隔符:“”)

Ios 无法转换类型为';字符串';到预期的参数类型';String.Element';(又名字符)错误 let str=“TestTest2Hello,playgroundTest” str.split(分隔符:“”),ios,swift,Ios,Swift,我有上面的代码,并且我得到错误“无法将“String”类型的值转换为预期的参数类型“String.Element”(又名“Character”)您能尝试下面的代码而不是第二行吗 let str = "<h1>Test</h1><h2>Test2</h2><h3>Hello, playground</h3><h3>Test</h3>" str.split(separator: &qu

我有上面的代码,并且我得到错误“无法将“String”类型的值转换为预期的参数类型“String.Element”(又名“Character”)

您能尝试下面的代码而不是第二行吗

let str = "<h1>Test</h1><h2>Test2</h2><h3>Hello, playground</h3><h3>Test</h3>"
str.split(separator: "<h3>")
str.components(分隔符:“”)
    str.components(separatedBy: "<h3>")