Saving UIPrinter to NSUserDefaults

空扰寡人 提交于 2019-12-01 14:06:13

You can't store a UIPrinter instance in NSUserDefaults. What you can do is save the printer's URL and then when your app starts again and you need the UIPrinter, read the URL from NSUserDefaults and use UIPrinter printerWithURL:.

You should use the url property to save in NSUserDefaults with setURL:forKey: .

Something like this:

NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];     
[defaults setURL:[self.SavedPrinter url] forKey:@"printer.url"];
[defaults synchronize];

And when you need the same printer again, create another UIPrinter with printerWithURL: using the url you have stored.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!