【问题标题】:use of undeclared type NSLinguisticTagScheme使用未声明的类型 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 上复制您的问题
  • 你能用命令行编译文件吗?

标签: swift4 macos-high-sierra nslinguistictagger


【解决方案1】:

更新 Xcode 解决了这个问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-03
    • 2017-12-27
    • 2017-02-21
    • 2018-12-28
    • 2015-04-15
    • 2017-07-09
    相关资源
    最近更新 更多