NSOpenPanel runModalforTypes

时间:2014-06-21 22:12:35

标签: cocoa nsopenpanel

我从Zarra / Long的核心动画一书中得到了这段代码。由于以下错误,它将无法编译:"' runModalForTypes'已被弃用"

- (IBAction)setMovieLocation:(id)sender {
NSOpenPanel *openPanel;

openPanel = [NSOpenPanel openPanel];
[openPanel setCanChooseDirectories: NO];
[openPanel setAllowsMultipleSelection: NO];
[openPanel setResolvesAliases: NO];
[openPanel setCanChooseFiles: NO];

if ([openPanel runModalForTypes:nil] == NSOKButton)
{
    [[qcLayer setValue:openPanel filename]
     forInputKey:[@"movie_location" ;]]
}
}

有可能修复吗?

1 个答案:

答案 0 :(得分:0)

NSOpenPanel继承自NSSavePanel时,您会发现此方法适合:

if ([openPanel runModal] == NSOKButton)

请参阅NSSavePanelNSOpenPanel

的文档