Swift-选择文件时警告(Cocoa) [英] Swift - warning when choosing files (Cocoa)
本文介绍了Swift-选择文件时警告(Cocoa)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的应用程序中创建一个按钮,以便使用Swift使用Finder选择文件.
I want to make a button in my app to select files with Finder using Swift.
@IBAction func selectFiles(sender : NSButton) {
let openDlg = NSOpenPanel()
openDlg.allowsMultipleSelection = true
openDlg.canChooseFiles = true
openDlg.canChooseDirectories = true
if openDlg.runModal() == NSOKButton{
files = openDlg.URLs
}
}
运行此代码时,会出现以下警告.
When I run this code, the following warning occurs.
Unable to simultaneously satisfy constraints:
(
"<NSAutoresizingMaskLayoutConstraint:0x608000095450 h=-&- v=-&- H:|-(0)-[NSView:0x608000125b40] (Names: '|':FIFinderView:0x600000143de0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x6080000954a0 h=-&- v=-&- H:[NSView:0x608000125b40]-(0)-| (Names: '|':FIFinderView:0x600000143de0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x608000095680 h=--& v=--& H:[FIFinderView:0x600000143de0(712)]>",
"<NSLayoutConstraint:0x60800008cbc0 H:[NSView:0x608000125a00]-(0)-| (Names: '|':NSView:0x608000125b40 )>",
"<NSLayoutConstraint:0x60800008cc10 H:|-(0)-[NSView:0x608000125a00] (Names: '|':NSView:0x608000125b40 )>",
"<NSAutoresizingMaskLayoutConstraint:0x608000092ed0 h=-&- v=-&- H:|-(0)-[NSClipView:0x100541110] (Names: '|':FI_TSidebarScrollView:0x6000001c1b30 )>",
"<NSAutoresizingMaskLayoutConstraint:0x608000092f20 h=-&- v=-&- H:[NSClipView:0x100541110]-(15)-| (Names: '|':FI_TSidebarScrollView:0x6000001c1b30 )>",
"<NSAutoresizingMaskLayoutConstraint:0x6080000935b0 h=-&- v=-&- H:|-(0)-[FI_TSidebarScrollView:0x6000001c1b30] (Names: '|':NSView:0x600000123660 )>",
"<NSAutoresizingMaskLayoutConstraint:0x608000093600 h=-&- v=-&- H:[FI_TSidebarScrollView:0x6000001c1b30]-(0)-| (Names: '|':NSView:0x600000123660 )>",
"<NSAutoresizingMaskLayoutConstraint:0x608000093790 h=-&- v=-&- H:|-(0)-[NSView:0x600000123660] (Names: '|':FI_TSidebarSplitView:0x600000143f40 )>",
"<NSAutoresizingMaskLayoutConstraint:0x6080000937e0 h=-&- v=-&- H:[NSView:0x600000123660]-(709)-| (Names: '|':FI_TSidebarSplitView:0x600000143f40 )>",
"<NSAutoresizingMaskLayoutConstraint:0x608000095270 h=-&- v=-&- H:|-(0)-[FI_TSidebarSplitView:0x600000143f40] (Names: '|':NSView:0x608000125a00 )>",
"<NSAutoresizingMaskLayoutConstraint:0x6080000952c0 h=-&- v=-&- H:[FI_TSidebarSplitView:0x600000143f40]-(0)-| (Names: '|':NSView:0x608000125a00 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x60800008cbc0 H:[NSView:0x608000125a00]-(0)-| (Names: '|':NSView:0x608000125b40 )>
Set the NSUserDefault NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints to YES to have -[NSWindow visualizeConstraints:] automatically called when this happens. And/or, break on objc_exception_throw to catch this in the debugger.
即使我没有摆脱此警告,我的应用程序也可以正常运行,但是我想知道如何删除它.
Even if I don't get rid of this warning, my app runs well, but I want to know how to remove it.
推荐答案
这是NSOpenPanel的问题.关于此的错误报告已提交给Apple,但是在他们修复该问题之前,恐怕您无能为力.好代码可以很好地运行:)
This is a problem with NSOpenPanel. A bug report on this has already been filed with Apple, but before they fix it I'm afraid there's not much you can do. Good thing your code runs well :)
这篇关于Swift-选择文件时警告(Cocoa)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文