草庐IT

macos - 自定义 NSFormatter swift 返回 nil

我在Swift中有一个NSFormatter,它附加到NSTextField。它可以防止输入非法字符,但是当我尝试访问下一个字段的值时,它给出了一个nil值。下面是类:classPSEntryNameFormatter:NSFormatter{overridefuncstringForObjectValue(obj:AnyObject?)->String?{ifobj==nil{println("stringForObjectValue:objisnil,returningnil")returnnil}ifleto=objas?String{println("stringForObje

macos - 自定义 NSFormatter swift 返回 nil

我在Swift中有一个NSFormatter,它附加到NSTextField。它可以防止输入非法字符,但是当我尝试访问下一个字段的值时,它给出了一个nil值。下面是类:classPSEntryNameFormatter:NSFormatter{overridefuncstringForObjectValue(obj:AnyObject?)->String?{ifobj==nil{println("stringForObjectValue:objisnil,returningnil")returnnil}ifleto=objas?String{println("stringForObje

macos - 使用 swift 读取 CFDictionary 中的值

我刚开始使用swift和cocoa。我正在尝试创建一个进行图像处理的基本应用。我已经得到了图像的所有信息:letimageRef:CGImageSourceRef=CGImageSourceCreateWithURL(url,nil).takeUnretainedValue()letimageDict:CFDictionaryRef=CGImageSourceCopyPropertiesAtIndex(imageRef,0,nil).takeUnretainedValue()字典包含以下信息:{ColorModel=Gray;DPIHeight=300;DPIWidth=300;Dep

macos - 使用 swift 读取 CFDictionary 中的值

我刚开始使用swift和cocoa。我正在尝试创建一个进行图像处理的基本应用。我已经得到了图像的所有信息:letimageRef:CGImageSourceRef=CGImageSourceCreateWithURL(url,nil).takeUnretainedValue()letimageDict:CFDictionaryRef=CGImageSourceCopyPropertiesAtIndex(imageRef,0,nil).takeUnretainedValue()字典包含以下信息:{ColorModel=Gray;DPIHeight=300;DPIWidth=300;Dep

macos - 如何在基于非文档的 Storyboard应用程序中处理 applicationShouldHandleReopen

我能想到的最好的是:funcapplicationShouldHandleReopen(sender:NSApplication,hasVisibleWindowsflag:Bool)->Bool{if!flag{letsb=NSStoryboard(name:"Main",bundle:nil)letcontroller=sb?.instantiateInitialController()asNSWindowControllercontroller.window?.makeKeyAndOrderFront(self)self.window=controller.window}retu

macos - 如何在基于非文档的 Storyboard应用程序中处理 applicationShouldHandleReopen

我能想到的最好的是:funcapplicationShouldHandleReopen(sender:NSApplication,hasVisibleWindowsflag:Bool)->Bool{if!flag{letsb=NSStoryboard(name:"Main",bundle:nil)letcontroller=sb?.instantiateInitialController()asNSWindowControllercontroller.window?.makeKeyAndOrderFront(self)self.window=controller.window}retu

macos - 如何将数据从 NSWindowController 传递到它的 NSViewController?

我的NSWindowController类中有一个IBOutlet的NSToolBar按钮,这是我的主窗口类:classMainWindowController:NSWindowController{@IBOutletweakvarmyButton:NSButton!//...}我有一个MainViewController类,它是主窗口的内容NSViewController。如何在我的内容NSViewController中访问这个按钮?有没有更好的方法来组织IBOutlets和Controller来促进这种访问? 最佳答案 从NSW

macos - 如何将数据从 NSWindowController 传递到它的 NSViewController?

我的NSWindowController类中有一个IBOutlet的NSToolBar按钮,这是我的主窗口类:classMainWindowController:NSWindowController{@IBOutletweakvarmyButton:NSButton!//...}我有一个MainViewController类,它是主窗口的内容NSViewController。如何在我的内容NSViewController中访问这个按钮?有没有更好的方法来组织IBOutlets和Controller来促进这种访问? 最佳答案 从NSW

macos - DocumentType 不使用 Swift 在 Xcode 6 Beta 5 中映射

我在Xcode6Beta4中使用Swift为OSX构建了一个基于文档的应用程序,它运行良好。但是,升级到Xcode6Beta5后,每次尝试打开文档窗口时,我都会收到以下错误消息:TheDocumentTypetypedoesn'tmaptoanyNSDocumentClass.我在信息屏幕中编辑了文档类型以尝试匹配类。我尝试了${PRODUCT_MODULE_NAME}.Document、MyApp.Document和简单的Document,但每次都收到相同的错误消息。最后,我尝试使用Swift创建一个全新的、基于模板的文档应用程序,但也没有成功。当我使用ObjectiveC创建一个新

macos - DocumentType 不使用 Swift 在 Xcode 6 Beta 5 中映射

我在Xcode6Beta4中使用Swift为OSX构建了一个基于文档的应用程序,它运行良好。但是,升级到Xcode6Beta5后,每次尝试打开文档窗口时,我都会收到以下错误消息:TheDocumentTypetypedoesn'tmaptoanyNSDocumentClass.我在信息屏幕中编辑了文档类型以尝试匹配类。我尝试了${PRODUCT_MODULE_NAME}.Document、MyApp.Document和简单的Document,但每次都收到相同的错误消息。最后,我尝试使用Swift创建一个全新的、基于模板的文档应用程序,但也没有成功。当我使用ObjectiveC创建一个新