IPhone - Save URL without setURL: forKey: and NSURL

Is there a way to save URLs with NSUserDefaults without setURL: forKey: only available for iOS 4.0 and later?

I upload HTML files locally using the urlllithpath file and it starts from the input page and the user can click on any. At the moment, every time the user starts it, he returns the default value in intro.htm. I would like to be able to save their current page in NSUserDefaults on viewdiddissapear and reload it next time, but cannot find any solutions other than setURL: forKey :. Does anyone know a solution?

+2
source share
1 answer

You can turn the url into a string:

[[NSUserDefaults standardUserDefaults]
 setObject:[url absoluteString] forKey:@"url"];

And vice versa:

NSURL *url = [NSURL URLWithString:[[NSUserDefaults standardUserDefaults]
                                   objectForKey:@"url"]];
+8
source

All Articles