Apple Developer Connection
Advanced Search
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page >

コンポジションファイルを取得する

QCRendererオブジェクトを作成するには、OpenGLコンテキストおよびQuartz Composerファイルが必要です。ユーザがコンポジションをアプリケーションアイコンまでドラッグした場合は、このNSApplicationデリゲートメソッドを実装し、後でQCRendererオブジェクトの作成時に使用できるようにファイルパスの名前を保持します。

- (BOOL) application:(NSApplication*)theApplication
                    openFile:(NSString*)filename
{
    _filePath = [filename retain];
 
    return YES;
}

ユーザがアイコンをダブルクリックしてアプリケーションを開いた場合は、次のコードをapplicationDidFinishLaunching:デリゲートメソッドに含めることで、コンポジションを指定するように求め、ファイルパス名を指定されたらそれを保持します。

NSOpenPanel *openPanel;
 
if(_filePath == nil)
    {
        openPanel = [NSOpenPanel openPanel];
        [openPanel setAllowsMultipleSelection:NO];
        [openPanel setCanChooseDirectories:NO];
        [openPanel setCanChooseFiles:YES];
        if([openPanel runModalForDirectory:nil
                    file:nil
                    types:[NSArray arrayWithObject:@"qtz"]] != NSOKButton)
            {
                NSLog(@"No composition file specified");
                [NSApp terminate:nil];
            }
        _filePath = [[[openPanel filenames] objectAtIndex:0] retain];
    }


< Previous PageNext Page >


Last updated: 2006-12-05




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice