Sunday, 27 April 2014

Post WDI - iPhone Storing App Preferences

iPhone Development (Xcode 5) (Cont'd)

iPhone Storing App Preferences   DONE
  • Application Preferences (aka Settings, User Defaults, User Preferences, Options)
    • Overall preference system where apps customise for users
  • Application Preferences System { low-level tasks of persisting preferences to iPhone with app preferences separate and backed up  
  • Design Principles
    • Opinionated Software { limit app preferences with an opinion on best ways to accomplish tasks serves larger market } 
    • Implicit (In-App) Preference Exposure { based on user actions using the app and returning to last state of app upon reuse }
    • Explicit Preference Exposure using Apples Settings Application { single location to customise iPhone Settings Bundle, but UI is limited }
    • Alternatively { customized toolbar with limited frequently used items and a 'more' button }
    • Examples { API access, streamline w default inputs saved to reduce user taps }
  • Utility App Template { contain info icon that animates a transition to a flipside view for setting app preferences when tapped }
  • Settings Bundle Template { generated from Resources group in sidebar it creates a Root.plist file editable in Property List Editor, which controls appearance of the app in the settings bundle where preferences may be set and retrieved from the preferences database and grouped. types may be edited (i.e. PSTextFieldSpecifier changed to PSMultiValueSpecifier). note that multiple PList files may be created (i.e. About, etc) }
  • Reading and Writing User Defaults
    • NSUserDefaults API { singleton pattern (only one instance object of class stored) class used to store app preferences as key/value pairs }
    • viewWillDissappear event { persist in saving key values when view disappears  (i.e. on/off state and levels as constants) using setBool and setFloat methods of standardUserDefaults method  associated with NSUserDefault singleton API. preferences stored in PList file (XML property list file) }
    • viewDidLoad event { read and use preferences when view appears upon application launch using floatForKey and boolForKey methods of NSUserDefaults API. set the preferences with a Helper Method setValuesFromPreferences, and cover the initial case with default settings using a dictionary of default preference keys and values to the registerDefaults method. Array Title String properties and Array of UITextFields setup by reading preferences current value from NSUserDefaults, and used for storage and editing. Store preferences into user defaults database using Utility Template App 'done' action instance }
  • In-App Preferences
    • FlipSideViewController (to implement table view Delegate and Data Source Protocols instead of using TableViewController) for Utility Template App (with Flipside View) 
      • Preferences Stored and Edited { added as subviews of table cells content view }

No comments:

Post a Comment