I've noticed that my app crashes if I:
- Use custom Swift class for NSWindow
- Add NSScrollView on the window
- Running a specific target(I have 2 more in this project, and both of them works fine in the same conditions)
The code calling it looks like:
guard let alertWindow = alert.window else {//It crashes here
//other code
return false
}
Class implementation is empty. It's just NSWindow subclass(if I use NSWindow everything is ok)
class CustomAlertWindow: NSWindow {
}
It works fine with an empty Objective-C subclass
@interface CustomAlertWindow: NSWindow
@end
@implementation CustomAlertWindow
@end
Have someone faced such kind of crash. Looks like it tries to subscribe to NSScrollView events. And somewhy it fails. Probably something is wrong in my target, or perhaps it's just a Cocoa/XCode/etc. BUG...
I'm unable to reproduce it in an empty project at the moment, but I'll keep trying.
When I overloaded addObserver method, I discovered that keyPath is "contentLayoutRect"
override func addObserver(_ observer: NSObject, forKeyPath keyPath: String, options: NSKeyValueObservingOptions = [], context: UnsafeMutableRawPointer?) {
super.addObserver(observer, forKeyPath: keyPath, options: options, context: context)
}
The same for both:
- Swift 3
- XCode Version 8.3.3 (8E3004b)
- macOS: 10.12.5 (16F73)
and
- Swift 3.2
- Xcode Version 9.0 (9A235)
- macOS: 10.13 (17A365)
P.S. Any way, thanks for attention.