macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

context

INDEX>AppKit>NSApplication

アプリケーションのディスプレイコンテキストを返します

Objective-C

@property(readonly, strong) NSGraphicsContext *context

Swift

var context: NSGraphicsContext? { get }

解説

アプリケーションのディスプレイコンテキストを返します。

設定値

( NSGraphicsContext * )

Swift

NSGraphicsContext

グラフィックスコンテキスト

フレームワーク

ApplicationKit

クラス

NSApplication

使用可能

10.0

編集時のバージョン

10.10

参照

例文

Objective-C

#import "Controller.h"

@implementation Controller

- (IBAction)pushButton:(id)sender
{
	NSGraphicsContext *context = [NSApp context];
	NSLog(@"context %@",[context description]);
	NSLog(@"%p",[context focusStack]); 
}


@end

Swift

//NSApplication aContext
    @IBAction func function059(sender: AnyObject) {
        //共有アプリケーションインスタンスを取得
        let anApplication = MyApplication.sharedApplication()
        var aContext : NSGraphicsContext = anApplication.context!
        
        NSLog("context = %@",aContext)
        var point : NSPoint  = aContext.patternPhase
        NSLog("%f,%f",point.x,point.y)
    }