diff --git a/AppPrefs/AppDelegate.cs b/AppPrefs/AppDelegate.cs index 87de9e9e..f109737b 100644 --- a/AppPrefs/AppDelegate.cs +++ b/AppPrefs/AppDelegate.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; using Foundation; using UIKit; @@ -12,7 +9,7 @@ namespace AppPrefs /// application events from iOS. /// [Register ("AppDelegate")] - public partial class AppDelegate : UIApplicationDelegate + public class AppDelegate : UIApplicationDelegate { // class-level declarations NSObject observer; @@ -21,6 +18,7 @@ namespace AppPrefs public override void FinishedLaunching (UIApplication application) { + Settings.LoadDefaultValues(); observer = NSNotificationCenter.DefaultCenter.AddObserver ((NSString)"NSUserDefaultsDidChangeNotification", DefaultsChanged); DefaultsChanged (null); } diff --git a/AppPrefs/AppPrefsViewController.cs b/AppPrefs/AppPrefsViewController.cs index f7c6dbe8..802b727f 100644 --- a/AppPrefs/AppPrefsViewController.cs +++ b/AppPrefs/AppPrefsViewController.cs @@ -1,5 +1,4 @@ using UIKit; -using CoreGraphics; using System; using Foundation; diff --git a/AppPrefs/Settings.cs b/AppPrefs/Settings.cs index 5ca7ae3c..7545b5ac 100644 --- a/AppPrefs/Settings.cs +++ b/AppPrefs/Settings.cs @@ -1,4 +1,3 @@ -using System; using Foundation; namespace AppPrefs @@ -31,7 +30,7 @@ namespace AppPrefs const string nameColorKey = "nameColorKey"; const string backgroundColorKey = "backgroundColorKey"; - static void LoadDefaultValues () + public static void LoadDefaultValues () { var settingsDict = new NSDictionary (NSBundle.MainBundle.PathForResource ("Settings.bundle/Root.plist", null)); @@ -61,14 +60,10 @@ namespace AppPrefs var appDefaults = new NSDictionary (firstNameKey, FirstName, lastNameKey, LastName, nameColorKey, (int)TextColor, backgroundColorKey, (int)BackgroundColor); NSUserDefaults.StandardUserDefaults.RegisterDefaults (appDefaults); - NSUserDefaults.StandardUserDefaults.Synchronize (); } public static void SetupByPreferences () { - var testValue = NSUserDefaults.StandardUserDefaults.StringForKey (firstNameKey); - if (testValue == null) - LoadDefaultValues (); FirstName = NSUserDefaults.StandardUserDefaults.StringForKey (firstNameKey); LastName = NSUserDefaults.StandardUserDefaults.StringForKey (lastNameKey); TextColor = (TextColors)(int)NSUserDefaults.StandardUserDefaults.IntForKey (nameColorKey);