NSPrintInfo printSettings archiving
In the NSPrintInfo documentation, when talking about the printSettings, it says: Adding keys to the dictionary is equivalent to calling the Core Printing function PMPrintSettingsSetValue. Your new keys are added to the current print settings and are saved with any user preset files generated by the Mac OS X printing system. Because the print settings are stored in a property list, any values you add to the dictionary must correspond to scalar types such as strings, numbers, dates, booleans, and data objects or collection types such as dictionaries and arrays. I took this to mean that so long as I store my own custom settings in the printSettings dictionary, then if I used NSArchiver and NSUnarchiver to save and restore the NSPrintInfo object, that my custom items would be stored along with the dictionary. It appears this is not the case. If I set some custom keys in the print into printSettings, then do the following: NSPrintInfo *oldPrintInfo = [self printInfo]; NSPrintInfo *newPrintInfo = [NSUnarchiver unarchiveObjectWithData:[NSArchiver archivedDataWithRootObject:[self printInfo]]]; My oldPrintInfo printSettings has all my added keys, and the newPrintInfo has only the standard keys. I want to save my custom keys with the print info, and the documentation says that this happens when it is stored by the printing system, so what do I need to do to be able to save it in my document? I realize that I could archive printSettings separately and re-populate the printinfo, but that seems pretty messy when the documentation says explicitly that there is a way of storing it so that the custom attributes are preserved. Thanks Gideon___ 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
Re: NSPrintInfo printSettings archiving
You probably want to use [[self printInfo] dictionary] and then archive the dictionary however you want. -- Scott Ribe scott_r...@elevated-dev.com http://www.elevated-dev.com/ (303) 722-0567 voice ___ 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
Re: NSPrintInfo printSettings archiving
The dictionary method only returns standard attributes: (gdb) po [oldPrintInfo dictionary] { NSBottomMargin = 72; NSCopies = 1; NSDetailedErrorReporting = 0; NSFaxNumber = ; NSFirstPage = 1; NSHorizonalPagination = 0; NSHorizontallyCentered = 1; NSJobDisposition = NSPrintSpoolJob; NSJobSavingFileNameExtensionHidden = 0; NSLastPage = 2147483647; NSLeftMargin = 72; NSMustCollate = 1; NSOrientation = 0; NSPagesAcross = 1; NSPagesDown = 1; NSPaperName = iso-a4; NSPaperSize = NSSize: {595, 842}; NSPrintAllPages = 1; NSPrintProtected = 0; NSPrintTime = 0001-01-01 10:00:00 +1000; NSPrinter = {\n\Device Description\ = {\n NSDeviceIsPrinter = YES;\n};\n\Language Level\ = 2;\nName = \Canon iP1700\;\nType = \Canon iP1700\;\n}; NSPrinterName = Canon iP1700; NSRightMargin = 72; NSSavePath = ; NSScalingFactor = 1; NSTopMargin = 72; NSVerticalPagination = 0; NSVerticallyCentered = 1; } (gdb) po [oldPrintInfo printSettings] { borderColor = #FF00; com_apple_print_DocumentTicket_PMSpoolFormat = application/pdf; com_apple_print_PrintSettings_PMColorSyncProfileID = 1875; com_apple_print_PrintSettings_PMCopies = 1; com_apple_print_PrintSettings_PMCopyCollate = 1; com_apple_print_PrintSettings_PMFirstPage = 1; com_apple_print_PrintSettings_PMLastPage = 2147483647; com_apple_print_PrintSettings_PMPageRange = ( 1, 2147483647 ); com_apple_print_ticket_type = com.apple.print.PrintSettingsTicket; pagesHigh = 5; pagesWide = 3; printBorder = 1; printMapBackground = 1; whatToPrint = 0; } As you can see, there are some attributes that seem to be mirrored between the dictionary and printSettings, but some that are unique to each, and the printSettings is the only place where my custom attributes are set (the first item and last 5 items in the printSettings are my custom attributes). Regards Gideon On 22/05/2010, at 12:46 AM, Scott Ribe wrote: You probably want to use [[self printInfo] dictionary] and then archive the dictionary however you want. ___ 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