码迷,mamicode.com
首页 > 系统相关 > 详细

NSOpenPanel 使用(MAC 打开文件夹对话框的使用)

时间:2014-10-27 10:54:44      阅读:1859      评论:0      收藏:0      [点我收藏+]

标签:style   color   io   os   ar   使用   for   sp   文件   

NSOpenPanel 使用(MAC 打开文件夹对话框的使用)

1.得到多个选择的文件

2.指定文件类型

-(NSString *)get_fullpath

{

    NSOpenPanel *panel = [NSOpenPanelopenPanel];

    NSArray* fileTypes = [[NSArrayalloc] initWithObjects:@"txt",@"doc", nil];

    [panel setMessage:@"select a file"];

    [panel setPrompt:@"OK"];

    [panel setCanChooseDirectories:NO];

    [panel setCanCreateDirectories:YES];

    

    [panel setCanChooseFiles:YES];

    [panel setAllowsMultipleSelection:YES];


    [panel setAllowedFileTypes:fileTypes];

    

    NSString *path_all=@"";

    NSArray *select_files;

    NSInteger result = [panel runModal];

    m_LB1.stringValue =@"";

    if (result ==NSFileHandlingPanelOKButton)

    {

        select_files = [panel filenames] ;

        for (int i=0; i<select_files.count; i++)

        {

            path_all= [select_files objectAtIndex:i];

            m_LB1.stringValue = [m_LB1.stringValuestringByAppendingString:path_all];

            m_LB1.stringValue = [m_LB1.stringValuestringByAppendingString:@"\n"];

            NSLog(path_all);

        }

    }

    return @"";

}

@end


以上在XCODE 4.6上 通过!



NSOpenPanel 使用(MAC 打开文件夹对话框的使用)

标签:style   color   io   os   ar   使用   for   sp   文件   

原文地址:http://blog.csdn.net/u013317006/article/details/40503687

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!