【发布时间】:2011-12-22 08:43:41
【问题描述】:
当我使用时
NSArray* fileTypes = [[NSArray alloc] initWithObjects:@"pdf", @"PDF", nil];
NSInteger result = [openPanel runModalForTypes:fileTypes];
它按预期工作(只能选择 pdf 文件),但是当我使用时
NSArray* fileTypes = [[NSArray alloc] initWithObjects:@"pdf", @"PDF", nil];
[openPanel setAllowedFileTypes:fileTypes];
NSInteger result = [openPanel runModal];
我可以选择所有类型的文件,而不仅仅是 pdf。文档说 runModalForTypes 已被弃用,我们应该使用第二种方式。我做错了吗?
【问题讨论】:
标签: macos cocoa nsopenpanel