Lecture 12

Lecture 12 - Stanford CS193p Developing Applications for...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Stanford CS193p Fall 2011 Developing Applications for iOS Fall 2011 Stanford CS193p
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Stanford CS193p Fall 2011 To day Persistence How to make things stick around between launchings of your app (besides NSUserDefaults )
Background image of page 2
Stanford CS193p Fall 2011 Persistence Property Lists Use writeToURL:atomically: and initWithContentsOfURL: in NSArray or NSDictionary Or NSUserDefaults if appropriate. Also NSPropertyListSerialization converts Property Lists to/from NSData . Archiving Objects Storing things in the Filesystem SQLite Core Data Next week
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Stanford CS193p Fall 2011 Archiving There is a mechanism for making ANY object graph persistent Not just graphs with NSArray , NSDictionary , etc. in them. For example, the view hierarchies you build in Interface Builder Those are obviously graphs of very complicated objects. Requires all objects in the graph to implement NSCoding protocol - (void)encodeWithCoder:(NSCoder *)coder; - initWithCoder:(NSCoder *)coder; It is extremely unlikely you will use this in this course Certainly not in the homework assignments. But almost certainly not in your Final Project either. There are other, simpler, (or more appropriate), persistence mechanisms (more on this later).
Background image of page 4
Stanford CS193p Fall 2011 Archiving Object graph is saved by sending all objects encodeWithCoder: - (void)encodeWithCoder:(NSCoder *)coder { [super encodeWithCoder:coder]; [coder encodeFloat:scale forKey:@“scale”]; [coder encodeCGPoint:origin forKey:@“origin”]; [coder encodeObject:expression forKey:@“expression”]; } Absolutely, positively must call super ’s version or your superclass’s data won’t get written out! Object graph is read back in with
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/25/2012 for the course CS 193P taught by Professor Evandoll during the Fall '09 term at Stanford.

Page1 / 12

Lecture 12 - Stanford CS193p Developing Applications for...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online