Use NSTrackingArea in project running, get print — Failed to set (contentViewController) user defined inspected property on (NSWindow): trackingArea options 0x3 do not specify when the tracking area is active

After I create a new project — macOS → App! And I new a NSTrackingArea object, add it on self.view in 'ViewController.swift', as following:

let opt = (

    NSTrackingArea.Options.mouseEnteredAndExited.rawValue |

    NSTrackingArea.Options.mouseMoved.rawValue

)

let trackingArea = NSTrackingArea(rect: kb_V!.frame, options: NSTrackingArea.Options(rawValue: opt), owner:self, userInfo: nil)

self.view .addTrackingArea(trackingArea)

But it gets the print "Failed to set (contentViewController) user defined inspected property on (NSWindow): trackingArea options 0x3 do not specify when the tracking area is active" when I'm running my project!

I feel so wonder about it, And I want to konw how to fix it~

Answered by Yohol in 676977022

Solved it, by adding a NSTrackingArea.Options.activeAlways.rawValue - Enum's rawValue

let opt = (
    NSTrackingArea.Options.mouseEnteredAndExited.rawValue |
        NSTrackingArea.Options.mouseMoved.rawValue |
        NSTrackingArea.Options.activeAlways.rawValue
)
let trackingArea = NSTrackingArea(rect: kb_V!.frame, options: NSTrackingArea.Options(rawValue: opt), owner:self, userInfo: nil)
Accepted Answer

Solved it, by adding a NSTrackingArea.Options.activeAlways.rawValue - Enum's rawValue

let opt = (
    NSTrackingArea.Options.mouseEnteredAndExited.rawValue |
        NSTrackingArea.Options.mouseMoved.rawValue |
        NSTrackingArea.Options.activeAlways.rawValue
)
let trackingArea = NSTrackingArea(rect: kb_V!.frame, options: NSTrackingArea.Options(rawValue: opt), owner:self, userInfo: nil)
Use NSTrackingArea in project running, get print — Failed to set (contentViewController) user defined inspected property on (NSWindow): trackingArea options 0x3 do not specify when the tracking area is active
 
 
Q