使用未申报类型的NSLinguisticTagScheme
问题描述:
我的代码在操场的工作,和Xcode中显示没有错误,但是当我编译命令行上的文件时,它用错误使用未申报类型的NSLinguisticTagScheme
use of undeclared type NSLinguisticTagScheme
and String has no member 'tokenType'
继承人的问题代码回来。
let tagSchemes : [NSLinguisticTagScheme] = [ .tokenType]
let tagger : NSLinguisticTagger = NSLinguisticTagger(tagSchemes: tagSchemes, options: 0)
let options : NSLinguisticTagger.Options = [ .omitPunctuation, .omitWhitespace]
tagger.string = text
let range = NSRange(location: 0, length: text.utf16.count)
tagger.enumerateTags(in: range, unit: .sentence, scheme: .tokenType, options: options, using:
{ tag, tokenRange, stop in
let token = (text as NSString).substring(with: tokenRange)
sentences.append(token)
})
任何想法?
答
更新Xcode解决了问题
从iOS 11开始可以使用'NSLinguisticTagScheme'。您是否检查过您的Deployment Target? –
是的,目前正在部署到macOS 10.13,使用swift 4 – aj604
无法在macOS上复制您的问题10.13 –