Reading URLs from NSOpenPanel causes crash with SIGABRT
This co开发者_开发百科de crashes with SIGABRT:
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
[openPanel runModalForTypes:nil];
NSArray* URLs = [openPanel URLs];
for (NSString* item in URLs)
{
NSLog(item); // here it crashes with SIGABRT
}
I don't see anything wrong with the code but I'm a beginner at Objective-C.
Try doing for (NSURL *url in URLs)
instead. For some reason, you are incorrectly using an NSString
.
Also, you should be logging like this: NSLog(@"%@", url);
This is the way you should do it. You shouldn't be passing the object directly to NSLog
.
精彩评论