最近升级到macOS Sierra版本10.12,Xcode版本8.2.1
以下代码适用于OS Sierra,但带有警告消息.它适用于以前的操作系统El Capitan 10.11,没有警告信息.
任何人都可以建议如何撕掉这条警告信息?
warning: <NSRemoteView: 0x618000123200> determined it was necessary to configure <NSVBOpenPanel: 0x102e816d0> to support remote view vibrancy
Run Code Online (Sandbox Code Playgroud)
我的代码如下:
@IBAction func btnChooseFile(_ sender: Any)
{
let dialog = NSOpenPanel()
dialog.title = "Choose a project file"
dialog.showsResizeIndicator = true
dialog.showsHiddenFiles = false
dialog.canChooseDirectories = false
dialog.canCreateDirectories = false
dialog.allowsMultipleSelection = false
dialog.allowedFileTypes = ["txt"]
if (dialog.runModal() == NSModalResponseOK) {
let result = dialog.url // Pathname of the file
if (result != nil) {
let path = …Run Code Online (Sandbox Code Playgroud) 我是OS X应用开发的新手。我设法建立了NSComboBox(可选择的,不可编辑的),单击动作按钮后就可以得到indexOfSelectedItem,工作正常。
如何检测变化的价值?当用户更改选择时,应使用哪种功能来检测新选择的索引?
我尝试使用NSNotification,但未传递新的更改值,始终是加载时的默认值。这是因为我将postNotificationName放在错误的位置,还是应该使用其他方法来获取更改的值?
我尝试搜索网络,视频和教程,但主要是为Objective-C编写的。我在SWIFT中找不到任何答案。
import Cocoa
class NewProjectSetup: NSViewController {
let comboxRouterValue: [String] = ["No","Yes"]
@IBOutlet weak var projNewRouter: NSComboBox!
@IBAction func btnAddNewProject(sender: AnyObject) {
let comBoxID = projNewRouter.indexOfSelectedItem
print(“Combo Box ID is: \(comBoxID)”)
}
@IBAction func btnCancel(sender: AnyObject) {
self.dismissViewController(self)
}
override func viewDidLoad() {
super.viewDidLoad()
addComboxValue(comboxRouterValue,myObj:projNewRouter)
self.projNewRouter.selectItemAtIndex(0)
let notificationCenter = NSNotificationCenter.defaultCenter()
notificationCenter.addObserver(
self,
selector: “testNotication:”,
name:"NotificationIdentifier",
object: nil)
NSNotificationCenter.defaultCenter().postNotificationName("NotificationIdentifier", object: projNewRouter.indexOfSelectedItem)
}
func testNotication(notification: NSNotification){
print("Found Combo ID \(notification.object)")
}
func addComboxValue(myVal:[String],myObj:AnyObject){
let myValno: Int = myVal.count …Run Code Online (Sandbox Code Playgroud) 使用Swift 3更新到Xcode 8后,以下代码不再有效
self.view.window?.styleMask = NSTitledWindowMask | NSMiniaturizableWindowMask
Run Code Online (Sandbox Code Playgroud)
请告诉我如何解决它?