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];
}
}];
}
It crashes when I try to save at [[NSUserDefaults standardUserDefaults] setObject:self.SavedPrinter forKey:@"SavedPrinter"];
and I get this message as a error -[UIPrinter encodeWithCoder:]: unrecognized selector sent to instance 0x7fb204062760
. I need it to remember what printer the user picked and remember it even when the app goes out of the background. If any one could help that would be great!