2

Is this a bug in swift ? or am i missing something here i have declared the following let opts = (NSLinguisticTaggerOptions.OmitWhitespace | NSLinguisticTaggerOptions.JoinNames)

i get the following error fatal error: Can't unwrap Optional.None Playground execution failed: error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0). The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation.

update if i inline the option in to the calling method, it seems to work

 let tagger = NSLinguisticTagger(tagSchemes:NSLinguisticTagger.availableTagSchemesForLanguage("en"), options: 3)

tagger.string = someString
    //if i inline the options it seems to work
    tagger.enumerateTagsInRange(r, scheme: NSLinguisticTagSchemeNameTypeOrLexicalClass, options:(NSLinguisticTaggerOptions.OmitWhitespace | NSLinguisticTaggerOptions.JoinNames)){
            tag,range,_,_ in
            let token = nsstr.substringWithRange(range)
            println("\(tag), \(token)")

        }
isaiah_p
  • 325
  • 1
  • 8

1 Answers1

2

For the options parameter, try Int(opts.toRaw()).

(The "3" that you tried worked because it is the raw version.)

Joshua C. Lerner
  • 1,910
  • 17
  • 12