开发者

Reading URLs from NSOpenPanel causes crash with SIGABRT

开发者 https://www.devze.com 2023-03-25 07:54 出处:网络
This co开发者_开发百科de crashes with SIGABRT: NSOpenPanel *openPanel= [NSOpenPanel openPanel];

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消