I am trying to save a UIPrinter object like this.
-(IBAction)setPrinterInSettings:(id)sender{
UIPrinterPickerController *picker = [UIPrinterPickerController printerPickerControllerWithInitiallySelectedPrinter:self.SavedPrinter];
[picker presentFromRect:self.settingsButton.frame inView:self.view animated:YES completionHandler:^(UIPrinterPickerController *controller, BOOL userDidSelect, NSError *err) {
if (userDidSelect) {
self.SavedPrinter = controller.selectedPrinter;
NSLog(@"self.SavedPrinter == %@",self.SavedPrinter);
[self saveCustomObject:self.SavedPrinter key:@"SavedPrinter"];
[[NSUserDefaults standardUserDefaults] setObject:self.SavedPrinter forKey:@"SavedPrinter"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}];
}
An attempt to save to failed [[NSUserDefaults standardUserDefaults] setObject:self.SavedPrinter forKey:@"SavedPrinter"];
, and I get this message as an error -[UIPrinter encodeWithCoder:]: unrecognized selector sent to instance 0x7fb204062760
. I need him to remember which printer the user selected and remember him even when the application goes beyond the background. If anyone could help, that would be great!
source
share