Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8168747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:37:48+00:00 2026-06-06T20:37:48+00:00

the background: I’m adding a print panel accessory view to a print dialog (using

  • 0

the background: I’m adding a print panel accessory view to a print dialog (using addAccessoryController:), with controls binded to NSPrintInfo printSettings values so the values are saved in the print presets. I’m having troubles observing printSettings changes. I’m building with SDK 10.6, testing on OS X 10.7.

Here is a code sample that should work in my understanding, but observeValueForKeyPath: is never called:

- (void)testKVO
{
  NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo];
  [printInfo addObserver:self forKeyPath:@"printSettings.foo" options:0 context:NULL];
  [printInfo setValue:@"bar" forKeyPath:@"printSettings.foo"]; // observeValueForKeyPath:ofObject:change:context: not called
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
  NSLog(@"%s %@ :: %@", _cmd, keyPath, object);
}

I also tried observing printSettings directly, with no more success, the observer method is not called either (the printSettings returned by NSPrintInfo is in fact of class NSPrintInfoDictionaryProxy):

- (void)testKVO
{
  NSMutableDictionary *printSettings = [[NSPrintInfo sharedPrintInfo] printSettings];
  [printSettings addObserver:self forKeyPath:@"foo" options:0 context:NULL];
  [printSettings setValue:@"bar" forKey:@"foo"]; // observeValueForKeyPath:ofObject:change:context: not called
}

I double checked that my KVO system works in normal conditions and calls the observer method:

- (void)testKVO
{
  NSMutableDictionary *printSettings = [NSMutableDictionary dictionary];
  [printSettings addObserver:self forKeyPath:@"foo" options:0 context:NULL];
  [printSettings setValue:@"bar" forKey:@"foo"]; // observeValueForKeyPath:ofObject:change:context: called at last!
}

So the question is: how can I observe printSettings modifications, especially to know when the user has chosen a print preset?

I’d also like the preview to be updated automatically with

- (NSSet *)keyPathsForValuesAffectingPreview
{
  return [NSSet setWithObjects:
          @"representedObject.printSettings.foo",
          nil];
}

there is an easy workaround for the preview update: adding an indirection level by redeclaring the properties directly on the NSViewController itself. But for the print preset change I have no clue.

In the end, here is the comment in NSPrintInfo.h:

- (NSMutableDictionary *)printSettings;

The print info’s print settings. You can put values in this dictionary to store them in any preset that the user creates while editing this print info with a print panel. Such values must be property list objects. This class is key-value coding (KVC) and key-value observing (KVO) compliant for “printSettings” so you can often bind controls in print panel accessory views directly to entries in this dictionary. You can also use this dictionary to get values that have been set by other parts of the printing system, like a printer driver’s print dialog extension (the same sort of values that are returned by the Carbon Printing Manager’s PMPrintSettingsGetValue() function). Other parts of the printing system often use key strings like “com.apple.print.PrintSettings.PMColorSyncProfileID” but dots like those in key strings wouldn’t work well with KVC, so those dots are replaced with underscores in keys that appear in this dictionary, as in “com_apple_print_PrintSettings_PMColorSyncProfileID”. You should use the same convention when adding entries to this dictionary.

Any help appreciated

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T20:37:50+00:00Added an answer on June 6, 2026 at 8:37 pm

    Well I found a way. There is an undocumented notification that is being sent when selecting a print preset or changing paper format, all that you have to do is add an observer:

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(printInfoDidChange:) name:@"NSPrintInfoDidChange" object:nil];
    

    That is not as straightforward as binding to printSettings keypaths, and I really don’t like using an undocumented notification (almost as bad as using private API in term of maintainability) but that’s the only way I could figure out to do the job.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background: I'm using the (fantastic) Vim plugin python-mode , which includes the pep8 linter.
Background - I am using paramiko to put files on a bunch of remote
Background: Using unix, codeigniter from localhost. I'd like to run a controllers via a
BACKGROUND I'm using VS 2010 on a machine where I installed .Net 4.5 which
Background: I am using Eclipse to develop an Android app. I have an xml
Background: At my company we are developing a bunch applications that are using the
Background I am writing and using a very simple CGI-based (Perl) content management tool
Background: I am using HtmlAgilityPack (.Net), so I'm forced to use XPath 1.0, which
Background: I am using node.js and express to create an API. I have implemented
Background: I am developing a web-based teaching program (using Drupal 7, if that matters)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.