Lec 12 Pickers CS 3800 Introduction to IOS programming Lecture 16 Summer 2011
Announcements Program 6 due Tonight Program 7 Tuesday: Intro To Graphics Lec 16 Persistence
Topics Persistence: –What? –Multi-tasking Persistence: –System User Preferences –NSUserDefaults –pList –NSData –other Lec 16 Persistence
Persistence Persistence: what? Persistence: Multi-tasking –turning off multi-tasking –applicationWillEnterForeground –applicationWillEnterBackground –applicationWillTerminate Lec 16 Persistence
App User Preferences System Settings, app?, both? Demo (ch 12) Lec 16 Persistence
Ch 11 Example Creating –Settings Bundle owner? Root.plist review structure,types Navigation Example Lec 16 Persistence
Ch 11 Example, continued Accessing from your app –[NSUserDefaults standardUserDefaults] –#defining keys –objectForKey –setters Multi-tasking concerns –Notifications –selector Lec 16 Persistence
Ch 12 Example Version 0 not in book uses NSUserDefaults Overview: –‘state’ to save? –Clearing the simulator –first time access issues Lec 16 Persistence
Ch 12 Example Version 0 continued Load state - where? first time access? add multiTasking Lec 16 Persistence
Ch 12 Example version 1 - Plist app Sandbox –Documents folder –Library - Preferences –Create a container object –add data to container –write container to plist file –Serialization Lec 16 Persistence
Ch 12 Example: archiving For generic ( complex ) models implement the NSCoding protocol –encodeWithCoder –initWithCoder –NSCopying Protocol Lec 16 Persistence
Ch 12 Example: archiving continued Persistence 2 ‘model’ FourLines : NSObject –encode/decode the fields –view controller archive un-archive Lec 16 Persistence
Persistence - other SQLite3 –relational database, Core Data Lec 16 Persistence