0

For example,

An NLTagger has this function where you pass options:

[_lexicalClassTagger enumerateTagsInRange:NSMakeRange(0, string.length)
                                         unit:NLTokenUnitWord
                                       scheme:NLTagSchemeLexicalClass
                                      options:(NLTaggerOmitPunctuation |
                                               NLTaggerOmitWhitespace |
                                               NLTaggerOmitOther)
                                   usingBlock:^(NLTag _Nullable tag,
                                                NSRange tokenRange,
                                                BOOL * _Nonnull stop){
        
        if (tag == NLTagNoun) {
         
            // Do something...    
        }
    }];

How can I create my own custom function where I can pass through options-like parameters in the same format?

(NLTaggerOmitPunctuation | NLTaggerOmitWhitespace | NLTaggerOmitOther)

A custom method like:

- (void)performActionsWithOptions:(CustomClassOptions)customClassOptions;

Call it like:

[customClass performActionsWithOptions:(CustomClassOption1 | CustomClassOption2)];

I can't figure out the data type since options in the example above is of type "NLTaggerOptions".

Vulkan
  • 1,004
  • 16
  • 44
  • You were missing key words: bit flag / bit mask, OptionSet (in Swift) for you search. And I guess that in the `if` you want `&` (see linked question). And the real data type is shown there https://developer.apple.com/documentation/naturallanguage/nltaggeroptions?language=objc, it's a enum of NSUInteger – Larme Jun 07 '21 at 13:41
  • How is `NLTaggerOptions` declared? – Willeke Jun 07 '21 at 13:53

0 Answers0