Xib loading crashes when it contains NSSCrollView

倖福魔咒の 提交于 2019-12-12 06:47:38

问题


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.


回答1:


All problems were connected to the Sparkle.framework.

I've just updated it. We had all problems described in bug discussion.

Hope nobody face similar problems =)

We had Sparkle version 1.8.0 . I'm ashamed =(



来源:https://stackoverflow.com/questions/47198173/xib-loading-crashes-when-it-contains-nsscrollview

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!