09-Data - CS193P - Lecture 9 iPhone Application Development...

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

View Full Document Right Arrow Icon
CS193P - Lecture 9 iPhone Application Development Data in Your iPhone App
Background image of page 1

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

View Full DocumentRight Arrow Icon
Announcements Presence 2 is due on Tuesday 5/5 at 11:59pm ! Questions?
Background image of page 2
Announcements Friday optional lectures will now be recorded ! Should become available on iTunes U if all goes well! ! This Friday: Loren Brichter (http://www.atebits.com )
Background image of page 3

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

View Full DocumentRight Arrow Icon
Announcements Final projects! ! Groups of 1-2 people ! Final 3 weeks of the course ! Due Sunday 6/7 at 11:59PM ! Presentations on Monday 6/8 from 12:15-3:15PM You must send us your proposal for approval ! Approval deadline is Monday 5/11 ! But the earlier you’re approved, the earlier you can start. .. Students retain ownership of final projects
Background image of page 4
Frequently Encountered Issues “Calling a method on object X doesn’t do anything!” ! Remember that in Objective-C, messaging nil is allowed ! If the method has a return value, it will return zero or nil ! Try inspecting the value of the variable with NSLog() or gdb
Background image of page 5

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

View Full DocumentRight Arrow Icon
Frequently Encountered Issues “My IBOutlet variables are nil!” ! Remember that view controllers don’t load their NIBs right away ! Don’t try to access IBOutlet variables in -init methods ! Instead, use -viewDidLoad or -viewWillAppear: ! -viewDidLoad called once after loading the view ! -viewWillAppear: called every time the view comes onscreen
Background image of page 6
Today’s Topics Data in Your iPhone App ! Saving & loading local data ! Accessing remote data over the Internet
Background image of page 7

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

View Full DocumentRight Arrow Icon
Today’s Topics Property Lists iPhone’s File System Archiving Objects The Joy of SQLite Web Services App Data Flow
Background image of page 8
Property Lists
Background image of page 9

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

View Full DocumentRight Arrow Icon
Property Lists Convenient way to store a small amount of data ! Arrays, dictionaries, strings, numbers, dates, raw data ! Human-readable XML or binary format NSUserDefaults class uses property lists under the hood
Background image of page 10
When Not to Use Property Lists More than a few hundred KB of data ! Loading a property list is all-or-nothing Complex object graphs Custom object types
Background image of page 11

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

View Full DocumentRight Arrow Icon
NSArray and NSDictionary convenience methods Operate recursively // Writing - (BOOL)writeToFile:(NSString *)aPath atomically:(BOOL)flag; - (BOOL)writeToURL:(NSURL *)aURL atomically:(BOOL)flag; // Reading - (id)initWithContentsOfFile:(NSString *)aPath; - (id)initWithContentsOfURL:(NSURL *)aURL;
Background image of page 12
Writing an Array to Disk NSArray *array = [NSArray arrayWithObjects:@“Foo”, [NSNumber numberWithBool:YES], [NSDate dateWithTimeIntervalSinceNow:60], nil]; [array writeToFile:@“MyArray.plist” atomically:YES]; <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd "> <plist version="1.0"> <array> <string>Foo</string> <true/> <date>2009-04-29T15:26:18Z</date> </array> </plist>
Background image of page 13

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

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

This note was uploaded on 10/29/2009 for the course CS 193D taught by Professor Staff during the Spring '08 term at Stanford.

Page1 / 56

09-Data - CS193P - Lecture 9 iPhone Application Development...

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

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