Q:
Do I have to update this NSUserDefaults?
I've been working on a music player and I've been using NSUserDefaults to keep track of which songs I've added to the playlist. I've been working with the MusicKit API and it seems like NSUserDefaults is not working the same way I expected it to. I have two problems:
The UISwitch appears to update the NSUserDefaults only when the app is active, but if the app is inactive the UISwitch is not updated. I've noticed this only when I have several songs and switch between them by clicking on the UISwitch. It appears to be some sort of caching problem where the old value gets returned no matter what.
At the moment I have a UISwitch at the bottom of my screen that should indicate whether the songs in the playlist are being played, however when I add songs to the playlist and switch between the songs I can still switch the UISwitch back and forth indicating I'm not currently playing any of the songs in the list. This shouldn't be the case, but obviously that's what is happening.
Any help would be greatly appreciated, I've been looking for hours online and have found no solution.
EDIT: If anyone has any suggestions on how to solve problem #2 I'd love to hear them.
A:
You are correct in using UserDefaults.
According to the documentation, your switch is likely updating the user defaults, but the changes are only visible when you are active.
Try doing your switch in viewWillAppear.
The A.C.A. was approved by the D.C. Circuit Court of Appeals on Sept. 27 and the three-judge panel of the U.S. Supreme Court is expected to release its opinion on the case by year's end.
Every Supreme Court justice has signed on to uphold the A.C.A. in principle, but the justices have not ruled on the government's appeal, either individually or collectively.
In his majority opinion, Justice Anthony M. Kennedy reasoned that the 2005 law was not "mandated" by Congress but instead "the result of a long-standing, well-intentioned, and entirely appropriate" attempt to attack discrimination based on gender.
Justice Antonin Scalia, writing for the three dissenting justices, said that discrimination "is so pernicious and so immoral that no civilized society can be359ba680
Related links:
コメント