当我使用
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 已被弃用,我们应该使用第二种方式。难道我做错了什么?