在NSOpenPanel中选择文件时出现此错误。
我正在使用xCode 6.1.1和Yosemite。
2015-02-19 21:21:11.396 Sagssystem[2239:56373] NSConcreteMutableAttributedString initWithString:: nil value
2015-02-19 21:21:11.399 Sagssystem[2239:56373] (
0 CoreFoundation 0x00007fff8bb9450c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8edb976e objc_exception_throw + 43
2 CoreFoundation 0x00007fff8bb943bd +[NSException raise:format:] + 205
3 Foundation 0x00007fff860ba5a7 -[NSConcreteMutableAttributedString initWithString:] + 129
4 FinderKit 0x00007fff8d345e88 -[FI_TColumnPreviewPropertyTaggingTokenFieldController viewLoaded] + 183
5 FinderKit 0x00007fff8d21a371 -[FI_TViewController awakeFromNib] + 106
6 CoreFoundation 0x00007fff8baa259f -[NSSet makeObjectsPerformSelector:] + 223
7 AppKit 0x00007fff89e4d90d -[NSIBObjectData nibInstantiateWithOwner:options:topLevelObjects:] + 1216
8 AppKit 0x00007fff8a02a342 -[NSNib _instantiateNibWithExternalNameTable:options:] + 677
9 AppKit 0x00007fff8a029f92 -[NSNib _instantiateWithOwner:options:topLevelObjects:] + 143
10 AppKit 0x00007fff8a029287 -[NSViewController loadView] + 272
11 FinderKit 0x00007fff8d21a41a -[FI_TViewController loadView] + 98
12 AppKit 0x00007fff89fa85e7 -[NSViewController _loadViewIfRequired] + 75
13 AppKit 0x00007fff89fa8551 -[NSViewController view] + 30
14 FinderKit 0x00007fff8d347a5e -[FI_TColumnPreviewController initCommon] + 61
15 FinderKit 0x00007fff8d21a2a7 -[FI_TViewController initWithNibName:bundle:] + 59
16 FinderKit 0x00007fff8d2d2c3e -[FI_TColumnViewController browser:previewViewControllerForLeafItem:] + 288
17 AppKit 0x00007fff8a2da31c -[NSBrowser _hasLeafViewControllerForItem:] + 156
18 AppKit 0x00007fff8a2c8fbf -[NSBrowser _isExpandableItem:] + 51
19 AppKit 0x00007fff8a2d1bb1 -[NSBrowser _doClickAndQueueSendingOfAction:] + 277
20 AppKit 0x00007fff8a2d13ff -[NSBrowser doClick:] + 384
21 FinderKit 0x00007fff8d2c921f -[FI_TColumnView doClick:] + 142
22 libsystem_trace.dylib 0x00007fff8d69fcd7 _os_activity_initiate + 75
23 AppKit 0x00007fff8a078671 -[NSApplication sendAction:to:from:] + 452
24 AppKit 0x00007fff8a08e006 -[NSControl sendAction:to:] + 86
25 AppKit 0x00007fff8a13e173 -[NSTableView _sendAction:to:row:column:] + 90
26 AppKit 0x00007fff8a13caa6 -[NSTableView mouseDown:] + 6506
27 AppKit 0x00007fff8a2e1216 -[NSBrowserTableView mouseDown:] + 195
28 FinderKit 0x00007fff8d2c355e -[FI_TBrowserTableView mouseDown:] + 693
29 AppKit 0x00007fff8a5ddcf0 -[NSWindow _reallySendEvent:isDelayedEvent:] + 13331
30 AppKit 0x00007fff89f83b14 -[NSWindow sendEvent:] + 468
31 AppKit 0x00007fff89f807f1 -[NSApplication sendEvent:] + 4183
32 AppKit 0x00007fff89ea9e08 -[NSApplication run] + 711
33 AppKit 0x00007fff89e24e64 NSApplicationMain + 1832
34 Sagssystem 0x0000000100045e62 main + 34
35 libdyld.dylib 0x00007fff8380a5c9 start + 1
)
我用这段代码打电话给NSOpenPanel:
NSOpenPanel *panel = [NSOpenPanel openPanel];
NSArray * fileTypes = [NSArray arrayWithObjects:@"png",@"jpg",@"jpeg",@"gif",@"pdf",nil];
[panel setAllowedFileTypes:fileTypes];
[panel setCanChooseFiles:YES];
[panel setCanChooseDirectories:NO];
[panel setAllowsMultipleSelection:YES]; // yes if more than one dir is allowed
[panel beginSheetModalForWindow:self.view.window completionHandler: ^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton) {
for (NSURL *fileURL in [panel URLs]) {
}
return;
} else {
[self dismissController:self];
}
}];
选择文件时,首先出现错误。 该应用程序不会崩溃,我确实得到了文件名。
希望有人可以帮忙:)