Re: Notification when displays are detected?
Re: Notification when displays are detected?
- Subject: Re: Notification when displays are detected?
- From: Tobias Zimmerman <email@hidden>
- Date: Wed, 30 Dec 2009 06:34:15 -0500
- Thread-topic: Notification when displays are detected?
Adding this method to your application delegate should be sufficient:
-(void)applicationDidChangeScreenParameters: (NSNotification *)notice
{
//Handle Display Change Here
}
If this isn't in the main class of your app, then you can make the class an
NSApp delgate by adding this line to the class's -(id)init method:
[NSApp setDelegate: self];
Someone may pipe in on why this is the wrong way to do it, but it has worked
for me. No need to set specific message centers etc. -- it is part of the
NSApplicationDelegate protocol, so delegates of NSApp automatically receive
the notice, in the same way as notices like "applicationDidFinishLaunching".
Search for "applicationDidChangeScreenParameters" in the documentation and
you should see it described in both the NSApplicationDelegate protocol and
in the reference for NSApplication itself.
> Message: 12
> Date: Tue, 29 Dec 2009 19:04:51 -0000
> From: "Paul Sanders" <email@hidden>
> Subject: Re: Notification when displays are detected?
> To: "Jacob Schwartz" <email@hidden>
> Cc: email@hidden
> Message-ID: <9C9B59CD428B41F89A65B7229DB9898B@PAULS>
> Content-Type: text/plain; charset="iso-8859-1"
>
> That looks OK to me. I do:
>
> NSNotificationCenter *dnc = [NSNotificationCenter defaultCenter];
> [dnc addObserver: self selector: @selector (didChangeScreenParameters:)
> name: NSApplicationDidChangeScreenParametersNotification object: nil];
>
> ...
>
> - (void) didChangeScreenParameters: (NSNotification *) notification
> {
> ...
> }
>
> What object is 'self' in your scenario? It needs to exist for the life of the
> app, obviously.
>
> Paul Sanders.
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden