iphone persistence for mere mortals

Post on 19-May-2015

3.589 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

iPhone Persistence talk I gave at 360|iDev in Spring 2008.

TRANSCRIPT

Code and Slides:http://thillerson.googlecode.com

iPhone Persistence For Mere Mortals Tony Hillerson

Software Architect

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

... or it means saving stuff.

Persistence

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

BTW: I’m a n00b

Persistence: Disclaimer

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: Savin’ stuff on ur foneYour options

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Settings SQLiteFilesystemThe Internets

Persistence: Options

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Settings SQLiteFilesystemThe Internets

Persistence: Options

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: Our Sweet App

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: Sweet Codeshttp://github.com/thillerson/grocery_getter/

Download

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: SettingsYours or Apple’s?

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Apple’s => Settings.bundle

Persistence: Settings

Yours => Roll your ownBoth end up in NSUserDefaults

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: Settings

Can be one of:NSData, NSString, NSNumber, NSDate, NSArray, or NSDictionary

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

[NSUserDefaults standardUserDefaults];

Persistence: Settings

NSUserDefaults *settings = [NSUserDefaults standardUserDefaults];

[settings setBool:YESforKey:@"shouldSortAfterComplete"];

[NSUserDefaults resetStandardUserDefaults];BOOL on = [settings boolForKey:@"shouldSortAfterComplete"];

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: SQLiteIt’s small, but it’s feisty!

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: SQLite

YO DAWG I HERD YOU LIEK DATA...

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: SQLite

SQLite - Embedded Relational Database written in C

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: SQLite

Embedded Relational Database

written in C

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

CocoaTouch:Terra Firma

SQLite:Hic Draconae

Sunt

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: SQLite

3 Takes on our Sweet App:• SQLite C API• fmdb + fmdb-migration-

manager• Aptiva’s ActiveRecord

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: SQLite

SQL C API:http://www.sqlite.org/c3ref/funclist.html

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: SQLite

• fmdb - Thin Wrapper around SQLite• fmdb-migration-manager - Rails-style

migrations using fmdb

• http://code.google.com/p/"ycode/• http://github.com/mocra/fmdb-

migration-manager/

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: SQLite

• Aptiva’s ActiveRecordIn software engineering, the active record pattern is a design pattern frequently found in software that stores its data in relational databases. It was named by Martin Fowler in his book Patterns of Enterprise Application Architecture.- http://en.wikipedia.org/wiki/Active_record_pattern

http://github.com/aptiva/activerecord/

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: SQLite

Quick! To the CODES!

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: A Few PointsTake two, they’re small!

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: Tips

Consider how your settings will be used

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: Tips

A database is an implementation detail

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: Tips

Encapsulation is your friend

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: Tips

Don’t forget to move your database

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: Tips

SQLite write speed is constrained by transactions

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: Tips

SQLite uses duck-typing

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: Tips

FMDB: executeQuery != executeUpdate

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: Tips

RTFS

Tuesday, March 3, 2009

Code and Slides:http://thillerson.googlecode.com

Persistence: Thank you!

slideshare.com/thillersongithub.com/thillerson twitter.com/thillersonbrightkite.com/thillerson

EffectiveUI.com

Tony HillersonSoftware Architect

Tuesday, March 3, 2009

top related