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" <p.sand...@alpinesoft.co.uk>
> Subject: Re: Notification when displays are detected?
> To: "Jacob Schwartz" <jakehschwa...@gmail.com>
> Cc: cocoa-dev@lists.apple.com
> Message-ID: <9c9b59cd428b41f89a65b7229db98...@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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to