简体   繁体   English

将NSOpenPanel的默认目录更改为“ Media”目录

[英]Changing the default directory of a NSOpenPanel to the “Media” directory

I'm developing a simple app for some students. 我正在为一些学生开发一个简单的应用程序。 In the app, a student has to select a video which they made in iMovie. 在该应用中,学生必须选择他们在iMovie中制作的视频。 I've already set up a NSOpenPanel for this, but I would like it to default to the movies directory, but not the ~/Movies directory, I'm aiming for the movies "directory" underneath the media title in Finder. 我已经为此设置了一个NSOpenPanel,但我希望它默认为电影目录,而不是~/Movies目录,我的目标是在Finder中媒体标题下的电影“目录”。 It is a pretty handy directory, because the students will be able to import videos directly from iMovie, instead of having to export and search for them. 这是一个非常方便的目录,因为学生可以直接从iMovie导入视频,而不必导出和搜索它们。 (Believe me, they screw this up all the time). (相信我,他们一直在搞砸)。

For extra clarity, this is a screenshot of the folder as seen in the open sheet: 为了更加清晰,这是该文件夹的屏幕截图,如打开的工作表所示: 在此处输入图片说明

(My computer is in dutch, hence the name "Films" instead of "Movies") (我的计算机在荷兰语中,因此名称为“ Films”而不是“ Movies”。)

您可以使用NSFileManager的URLsForDirectory:inDomains:方法,传入相应的NSSearchPathDirectory枚举器值(在您的情况下为NSMoviesDirectory):

NSURL* movieDirectory = [[[NSFileManager defaultManager] URLsForDirectory:NSMoviesDirectory inDomains:NSUserDomainMask] objectAtIndex:0];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM