我重写了
Xcode从Objective-C到
Swift生成的屏幕保护程序模板,当我尝试加载它时,我收到以下消息:
原文链接:https://www.f2er.com/swift/319258.htmlYou cannot use the BlahBlah screensaver with this version of MacOSX.
Please contact the vendor to get a new version of the screen saver.
我现在正在经营小牛队.这是否意味着Swift屏幕保护程序只能在优胜美地工作,甚至不在那里?
这是我用来替换Objetive-C的Swift代码:
import Foundation import ScreenSaver class BlahBlahView : ScreenSaverView { convenience override init() { self.init(frame: CGRectZero,isPreview: false) } override init(frame: NSRect,isPreview: Bool) { super.init(frame: frame,isPreview: isPreview) setAnimationTimeInterval(1.0 / 30.0) } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } override func startAnimation() { super.startAnimation() } override func stopAnimation() { super.stopAnimation() } override func drawRect(rect: NSRect) { super.drawRect(rect) } override func animateOneFrame() { } override func hasConfigureSheet() -> Bool { return false } override func configureSheet() -> NSWindow? { return nil } }
这些是我的项目设置:
这最初是在MacOSX 10.9上创建的Objective-C项目(没有Swift Screensaver模板),我正在使用的API,屏幕保护程序,已存在多年.