开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜