使用未声明的类型 NSLinguisticTagScheme
Posted
技术标签:
【中文标题】使用未声明的类型 NSLinguisticTagScheme【英文标题】:use of undeclared type NSLinguisticTagScheme 【发布时间】:2018-04-01 01:47:20 【问题描述】:我的代码在操场上运行,Xcode 没有显示任何错误,但是当我在命令行上编译文件时,它会返回错误
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)
)
有什么想法吗?
【问题讨论】:
NSLinguisticTagScheme
从 ios 11 开始可用。您检查过您的部署目标吗?
是的,目前正在部署到 macOS 10.13,使用 swift 4
无法在 macOS 10.13 上复制您的问题
你能用命令行编译文件吗?
【参考方案1】:
更新 Xcode 解决了这个问题
【讨论】:
以上是关于使用未声明的类型 NSLinguisticTagScheme的主要内容,如果未能解决你的问题,请参考以下文章
Objective-C 库的 Swift “使用未声明的类型”