macOS/iOS API解説

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

目次

cancelUserAttentionRequest:

INDEX>AppKit>NSApplication

ドックでアイコンが跳ねているのをやめさせます
-(void)cancelUserAttentionRequest:(NSInteger)request:

解説

ドックでアイコンが跳ねているのをやめさせます。
【NSRequestUserAttentionType】跳ね方
●NSCriticalRequest 重要な警告
●NSInformationalRequest お知らせ

返り値

( void )

なし

引数

( NSInteger )request

リクエスト

フレームワーク

ApplicationKit

クラス

NSApplication

Instance Methods

使用可能

10.1

参照

例文

#import "Controller.h"

@implementation Controller

NSTimer *timer=nil;
NSTimer *timer2=nil;

- (IBAction)pushButton:(id)sender
{
    id aSignature ;
    id invocation ;
    SEL aSelector ;
    id aSignature2 ;
    id invocation2 ;
    SEL aSelector2 ;
    //1つめのタイマー
    aSelector  = @selector( timerControl );
    aSignature = [ self methodSignatureForSelector:aSelector ];
    invocation = [ NSInvocation invocationWithMethodSignature:aSignature ];
    [ invocation setTarget: self ];
    [ invocation setSelector: aSelector ];
	
    //2つめのタイマー
    aSelector2  = @selector( stopJump );
    aSignature2 = [ self methodSignatureForSelector:aSelector2 ];
    invocation2 = [ NSInvocation invocationWithMethodSignature:aSignature2 ];
    [ invocation2 setTarget: self ];
    [ invocation2 setSelector: aSelector2 ];
	
    
	//アプリケーションを隠す
	[NSApp hide:nil];
	
	//1秒後に呼び出す(ジャンプさせる)
	timer = [NSTimer scheduledTimerWithTimeInterval:1
										 invocation:invocation
											repeats:NO];
	//10秒後に呼び出す(ジャンプとめる)
	timer2 = [NSTimer scheduledTimerWithTimeInterval:10
										  invocation:invocation2
											 repeats:NO];
	
}
-(void) timerControl{
	int i;
	//繰り返し呼び出す
	i = [NSApp requestUserAttention:NSCriticalRequest];
	NSLog(@"Start");
	NSLog(@"跳ねています。");
	NSLog(@"10秒後に止まります");
}
-(void) stopJump{
	[NSApp cancelUserAttentionRequest:NSCriticalRequest];
	/*
	【NSRequestUserAttentionType】跳ね方
	●NSCriticalRequest 重要な警告
	●NSInformationalRequest お知らせ
	*/
	NSLog(@"stop");
}
@end



//NSApplication requestUserAttention
    @IBAction func function060(sender: AnyObject) {
        //共有アプリケーションインスタンスを取得
        let anApplication = MyApplication.sharedApplication()
        anApplication.requestUserAttention(NSRequestUserAttentionType.CriticalRequest)
        //デアクティベートして
        anApplication.hide(self) //deactivate()
        //3秒後にユーザーアテンションを
        var startTimer = NSTimer.scheduledTimerWithTimeInterval(3.0, target: self, selector: Selector("requestAttention:"), userInfo: nil, repeats: false)
        //10秒後にユーザーアテンションを
        var stopTimer = NSTimer.scheduledTimerWithTimeInterval(10.0, target: self, selector: Selector("cancelAttention:"), userInfo: nil, repeats: false)
        
    }
    //タイマーが起動した時の実行メソッド ドックで跳ねる
    func requestAttention(timer:NSTimer!) {
        //共有アプリケーションインスタンスを取得
        let anApplication = MyApplication.sharedApplication()
        //ユーザーアテンションを開始
        NSLog("start attention")
        anApplication.requestUserAttention(NSRequestUserAttentionType.CriticalRequest)
    }
    //タイマーが起動した時の実行メソッド ドックではねているのをやめる
    func cancelAttention(timer:NSTimer!) {
        //共有アプリケーションインスタンスを取得
        let anApplication = MyApplication.sharedApplication()
        //ユーザーアテンションを停止
        NSLog("stop attention")
        anApplication.cancelUserAttentionRequest(0)
    }