Closed hwealnegn closed 9 years ago
I had pretty much the exact same issue. It seems like configureView
might be called before you try to load the link from the last session. So whenever the app starts, configureView
will overwrite the value you have saved in NSUserDefaults
with a null value. To prevent this, try checking if the current link you want to save is null or not, if null, then just return from configure view.
Good suggestion...
Ah, that's a really good point. Thanks so much!
You're welcome! I spent quite some time on this so I thought I'd help :)
I'm having trouble keeping my last viewed article saved in NSUserDefaults. The way I've been saving the article link is to save the string to a defaults object in my 'configure view' method (i.e. as the view is being configured, save the link of the article that's being configured). When the app is running, I can see in my log that this defaults object is updated when I click on different articles. However, when I stop the app and re-open it, the object is empty (null) according to my log. I have included [defaults synchronize] and I haven't run into this issue with other information I'm saving (ex. the favorited articles) so I'm not sure what's going wrong...