in Education by
I have a class which has 2 sets of getter & setters. 1 set is the traditional type. These work as expected: var userEmail : String { get { return UserDefaults.standard.string(forKey: UserDefaultKeys.profileEmail) ?? "" } set (newValue) { UserDefaults.standard.set(newValue, forKey: UserDefaultKeys.profileEmail) UserDefaults.standard.synchronize() } } var podSerialNum : Int { get { return UserDefaults.standard.integer(forKey: UserDefaultKeys.profilePodSN) } set (newValue) { UserDefaults.standard.set(newValue, forKey: UserDefaultKeys.profilePodSN) UserDefaults.standard.synchronize() } } var podID : Int { get { return UserDefaults.standard.integer(forKey: UserDefaultKeys.profilePodID) } set (newValue) { UserDefaults.standard.set(newValue, forKey: UserDefaultKeys.profilePodID) UserDefaults.standard.synchronize() } } The other gets/sets all properties at once. var userProfile: (email:String?, podSn:String?, podId:String?) { get { return ( UserDefaults.standard.value(forKey: UserDefaultKeys.profileEmail) as? String, UserDefaults.standard.value(forKey: UserDefaultKeys.profilePodSN) as? String, UserDefaults.standard.value(forKey: UserDefaultKeys.profilePodID) as? String) } set { UserDefaults.standard.set(newValue.email, forKey: UserDefaultKeys.profileEmail) UserDefaults.standard.set(newValue.podSn, forKey: UserDefaultKeys.profilePodSN) UserDefaults.standard.set(newValue.podId, forKey: UserDefaultKeys.profilePodID) UserDefaults.standard.synchronize() } } userProfile.podSn always returns nil. However userProfile.email & userProfile.podId work as expected. Also, the direct getter (podSerialNum) works. What am I missing? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

Related questions

0 votes
    Why does UIImageView remove from Array when I used removeFromSuperview() with Swift? // display UIImageView var ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 18, 2022 in Education by JackTerrance
0 votes
    In my password reset function the user can put in whatever he/she wants. It does not even needs ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    When you start the application, you should get a line from the Firestore documents and write to an array, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    trying to change method to update the data, because with reloadData have lag let oldIns = insertCounter ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 12, 2022 in Education by JackTerrance
0 votes
    I've searched Apple's documentation, open source projects, and Google, and I cannot seem to find any ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I am simply trying to read each character from a file and print them in the screen. For testing, I tried to print ... ("count.txt"); } void CountLetters(string filename) { cout...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    I am simply trying to read each character from a file and print them in the screen. For testing, I tried to print ... ("count.txt"); } void CountLetters(string filename) { cout...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    What does Rhino do when the getter and setter methods exist? (a) It becomes JavaScript properties (b) ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    I have have no error in my code. But my condition, finally don't work. const togglePeronsHandler = ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    I have have no error in my code. But my condition, finally don't work. const togglePeronsHandler = ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 22, 2022 in Education by JackTerrance
0 votes
    I have have no error in my code. But my condition, finally don't work. const togglePeronsHandler = ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 22, 2022 in Education by JackTerrance
0 votes
    A jar contains 24 marbles. Some of these are green and others are blue. If a marble is drawn at random from ... marbles in the jar. Select the correct answer from above options...
asked Nov 23, 2021 in Education by JackTerrance
0 votes
0 votes
    I have a Docker container with MariaDB installed. I am not using any volumes. [vagrant@devops ~]$ sudo ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 14, 2022 in Education by JackTerrance
0 votes
    So I'm basically finished with a program, and at the end of it I'm printing Strings from an array to a file. The array may ... the code I'm using to check for null for(int i=0;i...
asked Feb 13, 2022 in Education by JackTerrance
...