SlideShare a Scribd company logo
1 of 30
DATA MODEL
Building our App
OVERVIEW
• Lesson 1: Introductions
• Lesson 2: iOS specifics
• Lesson 3: Data Model
• Lesson 4: Logic (Controller) & Interface
LESSON 3: DATA MODEL
• Hour 1: Local Storage and Data Class
• Hour 2: Dictionary and User Defaults
• Hour 3: Save to File
Local Storage and Data Class
• Instantiating objects from classes (NSObject)
keep your object’s data in your app/device
memory
• These data “disappears” when your app is
shut down or if you shut down/reboot your
phone
• To persist your data for your user, you need
“local storage” (i.e. data is written into our
Local Storage?
Local Storage?
<Application Home>/AppName.app
• Known as the bundle directory
• Do not write anything into this directory
• To prevent tampering, the bundle directory is
signed at installation time
• If you write into this directory after your app
launches, your app cannot be launched again
Commonly used directories for
Storage
<Application Home>/Documents/
• Store critical user documents and app data files
• Critical data refers to any data that cannot be re-
created by our app
• Contents of this directory can be made available to
user through file sharing
• Contents of this directory are backed up by iTunes
Commonly used directories for
Storage
<Application Home>/Documents/Inbox/
• Use this directory to access files that your app was
asked to open by outside entities, e.g. Mail program
• Your app can read and delete files in this directory but
cannot create new files or write into existing files
• If user needs to edit file in this directory, app must
silently move it out of directory before making changes
• Contents of this directory are backed up by iTunes
Commonly used directories for
Storage
<Application Home>/Library/
• Non-user data files. This directory should not be used for user data files. Use it for your app
support files.
• The contents of this directory, except for the Caches subdirectory, are backed up by iTunes
• iOS 5.0 & earlier, put app support files in <Application Home>/Library/Caches so these files
don’t get backed up
• iOS 5.0.1 and later, app support files go into <Application Home>/Library/Application Support
directory and is applied with the com.apple.MobileBackup extended attribute to each support
file so files do not get backed up to either iTunes or iCloud
• If you have a lot of support files, store them all in a custom sub-directory and apply the
extended attribute to that sub-directory
• Data cache files are placed in <Application Home>/Library/Caches directory. Database cache
files, downloadable content used by magazine, newspaper and map apps are also stored here.
Your app needs to be able to gracefully handle situations where cached data is deleted by the
system to free up disk space
Commonly used directories for
Storage
<Application Home>/tmp/
• This directory is used to place data which we
do not need to keep for extended periods of
time
• It’s a good habit to delete files in this tmp
directory when we no longer need to use the
file we have placed there temporarily.
Commonly used directories for
Storage
• User Defaults (the ‘standard’ plist)
• Different file types (PDFs, text, doc, images
as png, jpg etc etc)
• CoreData (SQLite database)
• 3rd party solutions like Realm.io
Options for Local Storage?
User Defaults, also known as “Shared
Preferences”
• Key/value pairs
• Managed through Objective-C
• Stored in XML files that are managed through
Apple’s API
• Stored in unencrypted format (“plain text”)
Options for Local Storage?
File Storage
• Files can be created and read on disk
• No special file type, so store any file type that
you like (XML, JSON, delimited data csv, PDF,
png, jpg etc)
• Store these files “internal to app” or “external to
app” (in a shared file locations, such a Photo
Albums)
Options for Local Storage?
SQLite and Core Data
• Structured data with relationships can be saved into
an SQLite database
• iOS provides built-in support for SQLite
(www.sqlite.org)
• All classes and interfaces are in CoreData package
• Database files are stored in “internal location” in
app (within the app sandbox)
Options for Local Storage?
• We can use User Defaults
• Each note can be represented as a key-value pair in User
Defaults
‣ key: a unique date-time stamp
‣ value: string
• Practical example: User defaults (NSUserDefaults)
• Practical example: File Storage
How do we store Notes?
• Representation of what your app does (using custom
classes, subclass from NSObject for example)
• Spaceship game app will have Spaceship class,
TakeNotes app will have Note class, Painting app
could define a Image class
• Can subclass from UIDocument as well if we want to
define a document-based data model
• Other possibilities if using CoreData
(NSManagedObject) or Realm.io (RLMObject)
Data model objects
Create our “Data” class for
Notes
Create our “Data” class for
Notes
Create our “Data” class for
Notes
Create our “Data” class for
Notes
Create our “Data” class for
Notes
Dictionary and User Defaults
Our first method
Our first method
Other methods
Save to File
Save into Filesystem
Retrieve from Filesystem
WHAT’S NEXT
• Lesson 1: Introductions
• Lesson 2: iOS specifics
• Lesson 3: Data Model
• Lesson 4: Logic (Controller) & Interface

More Related Content

What's hot

MVC and Entity Framework 4
MVC and Entity Framework 4MVC and Entity Framework 4
MVC and Entity Framework 4James Johnson
 
Learn Entity Framework in a day with Code First, Model First and Database First
Learn Entity Framework in a day with Code First, Model First and Database FirstLearn Entity Framework in a day with Code First, Model First and Database First
Learn Entity Framework in a day with Code First, Model First and Database FirstJibran Rasheed Khan
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)David McCarter
 
Entity Framework Database and Code First
Entity Framework Database and Code FirstEntity Framework Database and Code First
Entity Framework Database and Code FirstJames Johnson
 
Introducing object oriented programming (oop)
Introducing object oriented programming (oop)Introducing object oriented programming (oop)
Introducing object oriented programming (oop)Hemlathadhevi Annadhurai
 
Introduction to SQL Alchemy - SyPy June 2013
Introduction to SQL Alchemy - SyPy June 2013Introduction to SQL Alchemy - SyPy June 2013
Introduction to SQL Alchemy - SyPy June 2013Roger Barnes
 
C# Framework class library
C# Framework class libraryC# Framework class library
C# Framework class libraryPrem Kumar Badri
 
Integrating Doctrine with Laravel
Integrating Doctrine with LaravelIntegrating Doctrine with Laravel
Integrating Doctrine with LaravelMark Garratt
 
Development Lifecycle: From Requirement to Release
Development Lifecycle: From Requirement to ReleaseDevelopment Lifecycle: From Requirement to Release
Development Lifecycle: From Requirement to ReleaseJulie Meloni
 

What's hot (16)

Introduction to Apache Solr
Introduction to Apache SolrIntroduction to Apache Solr
Introduction to Apache Solr
 
MVC and Entity Framework 4
MVC and Entity Framework 4MVC and Entity Framework 4
MVC and Entity Framework 4
 
Stored procedures
Stored proceduresStored procedures
Stored procedures
 
Learn Entity Framework in a day with Code First, Model First and Database First
Learn Entity Framework in a day with Code First, Model First and Database FirstLearn Entity Framework in a day with Code First, Model First and Database First
Learn Entity Framework in a day with Code First, Model First and Database First
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
 
Entity Framework Database and Code First
Entity Framework Database and Code FirstEntity Framework Database and Code First
Entity Framework Database and Code First
 
SQL overview and software
SQL overview and softwareSQL overview and software
SQL overview and software
 
Introducing object oriented programming (oop)
Introducing object oriented programming (oop)Introducing object oriented programming (oop)
Introducing object oriented programming (oop)
 
Where to save my data, for devs!
Where to save my data, for devs!Where to save my data, for devs!
Where to save my data, for devs!
 
Core Data
Core DataCore Data
Core Data
 
Sql lite presentation
Sql lite presentationSql lite presentation
Sql lite presentation
 
Introduction to SQL Alchemy - SyPy June 2013
Introduction to SQL Alchemy - SyPy June 2013Introduction to SQL Alchemy - SyPy June 2013
Introduction to SQL Alchemy - SyPy June 2013
 
Yql ans geo
Yql ans geoYql ans geo
Yql ans geo
 
C# Framework class library
C# Framework class libraryC# Framework class library
C# Framework class library
 
Integrating Doctrine with Laravel
Integrating Doctrine with LaravelIntegrating Doctrine with Laravel
Integrating Doctrine with Laravel
 
Development Lifecycle: From Requirement to Release
Development Lifecycle: From Requirement to ReleaseDevelopment Lifecycle: From Requirement to Release
Development Lifecycle: From Requirement to Release
 

Viewers also liked

とりあえず使うScalaz
とりあえず使うScalazとりあえず使うScalaz
とりあえず使うScalazShuya Tsukamoto
 
Functional Programming, Is It Worth It?
Functional Programming, Is It Worth It?Functional Programming, Is It Worth It?
Functional Programming, Is It Worth It?Andrew Rollins
 
iOS Beginners Lesson 4
iOS Beginners Lesson 4iOS Beginners Lesson 4
iOS Beginners Lesson 4Calvin Cheng
 
An introduction to functional programming with Swift
An introduction to functional programming with SwiftAn introduction to functional programming with Swift
An introduction to functional programming with SwiftFatih Nayebi, Ph.D.
 
16 CoreData
16 CoreData16 CoreData
16 CoreDataTom Fan
 
Core Data in Motion
Core Data in MotionCore Data in Motion
Core Data in MotionLori Olson
 
Things you might have missed from CoreData
Things you might have missed from CoreDataThings you might have missed from CoreData
Things you might have missed from CoreDataSergey Pronin
 
REST/JSON/CoreData Example Code - A Tour
REST/JSON/CoreData Example Code - A TourREST/JSON/CoreData Example Code - A Tour
REST/JSON/CoreData Example Code - A TourCarl Brown
 
Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Platonov Sergey
 
Core Data without headaches
Core Data without headachesCore Data without headaches
Core Data without headachesAbraham Barrera
 
CoreData - there is an ORM you can like!
CoreData - there is an ORM you can like!CoreData - there is an ORM you can like!
CoreData - there is an ORM you can like!Tomáš Jukin
 
Functional Programming for OO Programmers (part 1)
Functional Programming for OO Programmers (part 1)Functional Programming for OO Programmers (part 1)
Functional Programming for OO Programmers (part 1)Calvin Cheng
 
Functional Programming for OO Programmers (part 2)
Functional Programming for OO Programmers (part 2)Functional Programming for OO Programmers (part 2)
Functional Programming for OO Programmers (part 2)Calvin Cheng
 
What Would Steve Do? 10 Lessons from the World's Most Captivating Presenters
What Would Steve Do? 10 Lessons from the World's Most Captivating PresentersWhat Would Steve Do? 10 Lessons from the World's Most Captivating Presenters
What Would Steve Do? 10 Lessons from the World's Most Captivating PresentersHubSpot
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with DataSeth Familian
 

Viewers also liked (18)

とりあえず使うScalaz
とりあえず使うScalazとりあえず使うScalaz
とりあえず使うScalaz
 
Functional Programming, Is It Worth It?
Functional Programming, Is It Worth It?Functional Programming, Is It Worth It?
Functional Programming, Is It Worth It?
 
iOS Beginners Lesson 4
iOS Beginners Lesson 4iOS Beginners Lesson 4
iOS Beginners Lesson 4
 
An introduction to functional programming with Swift
An introduction to functional programming with SwiftAn introduction to functional programming with Swift
An introduction to functional programming with Swift
 
16 CoreData
16 CoreData16 CoreData
16 CoreData
 
Core Data in Motion
Core Data in MotionCore Data in Motion
Core Data in Motion
 
A CoreData Journey
A CoreData JourneyA CoreData Journey
A CoreData Journey
 
Things you might have missed from CoreData
Things you might have missed from CoreDataThings you might have missed from CoreData
Things you might have missed from CoreData
 
REST/JSON/CoreData Example Code - A Tour
REST/JSON/CoreData Example Code - A TourREST/JSON/CoreData Example Code - A Tour
REST/JSON/CoreData Example Code - A Tour
 
Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”
 
Core Data without headaches
Core Data without headachesCore Data without headaches
Core Data without headaches
 
CoreData - there is an ORM you can like!
CoreData - there is an ORM you can like!CoreData - there is an ORM you can like!
CoreData - there is an ORM you can like!
 
Functional Programming for OO Programmers (part 1)
Functional Programming for OO Programmers (part 1)Functional Programming for OO Programmers (part 1)
Functional Programming for OO Programmers (part 1)
 
Functional Programming for OO Programmers (part 2)
Functional Programming for OO Programmers (part 2)Functional Programming for OO Programmers (part 2)
Functional Programming for OO Programmers (part 2)
 
What Would Steve Do? 10 Lessons from the World's Most Captivating Presenters
What Would Steve Do? 10 Lessons from the World's Most Captivating PresentersWhat Would Steve Do? 10 Lessons from the World's Most Captivating Presenters
What Would Steve Do? 10 Lessons from the World's Most Captivating Presenters
 
How Google Works
How Google WorksHow Google Works
How Google Works
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with Data
 
Build Features, Not Apps
Build Features, Not AppsBuild Features, Not Apps
Build Features, Not Apps
 

Similar to iOS Beginners Lesson 3

File system in iOS
File system in iOSFile system in iOS
File system in iOSPurvik Rana
 
Android local databases
Android local databasesAndroid local databases
Android local databasesFatimaYousif11
 
Embedded Systems: Lecture 14: Introduction to GNU Toolchain (Binary Utilities)
Embedded Systems: Lecture 14: Introduction to GNU Toolchain (Binary Utilities)Embedded Systems: Lecture 14: Introduction to GNU Toolchain (Binary Utilities)
Embedded Systems: Lecture 14: Introduction to GNU Toolchain (Binary Utilities)Ahmed El-Arabawy
 
Hacking and Securing iOS Apps : Part 1
Hacking and Securing iOS Apps : Part 1Hacking and Securing iOS Apps : Part 1
Hacking and Securing iOS Apps : Part 1Subhransu Behera
 
358 33 powerpoint-slides_16-files-their-organization_chapter-16
358 33 powerpoint-slides_16-files-their-organization_chapter-16358 33 powerpoint-slides_16-files-their-organization_chapter-16
358 33 powerpoint-slides_16-files-their-organization_chapter-16sumitbardhan
 
Android datastorage
Android datastorageAndroid datastorage
Android datastorageKrazy Koder
 
Android project architecture
Android project architectureAndroid project architecture
Android project architectureSourabh Sahu
 
CNIT 121: 13 Investigating Mac OS X Systems
CNIT 121: 13 Investigating Mac OS X SystemsCNIT 121: 13 Investigating Mac OS X Systems
CNIT 121: 13 Investigating Mac OS X SystemsSam Bowne
 
iOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for BeginnersiOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for BeginnersRyanISI
 
Windows Phone 8 - 4 Files and Storage
Windows Phone 8 - 4 Files and StorageWindows Phone 8 - 4 Files and Storage
Windows Phone 8 - 4 Files and StorageOliver Scheer
 
Selecting And Protecting The Right Sharepoint Backup Targets Sps Michigan
Selecting And Protecting The Right Sharepoint Backup Targets Sps MichiganSelecting And Protecting The Right Sharepoint Backup Targets Sps Michigan
Selecting And Protecting The Right Sharepoint Backup Targets Sps MichiganChristopher Bunn
 
Mobile Application Development -Lecture 11 & 12.pdf
Mobile Application Development -Lecture 11 & 12.pdfMobile Application Development -Lecture 11 & 12.pdf
Mobile Application Development -Lecture 11 & 12.pdfAbdullahMunir32
 

Similar to iOS Beginners Lesson 3 (20)

File system in iOS
File system in iOSFile system in iOS
File system in iOS
 
Storage 8
Storage   8Storage   8
Storage 8
 
Android local databases
Android local databasesAndroid local databases
Android local databases
 
Asp folders and web configurations
Asp folders and web configurationsAsp folders and web configurations
Asp folders and web configurations
 
Asp .net folders and web.config
Asp .net folders and web.configAsp .net folders and web.config
Asp .net folders and web.config
 
iOS Application Pentesting
iOS Application PentestingiOS Application Pentesting
iOS Application Pentesting
 
Embedded Systems: Lecture 14: Introduction to GNU Toolchain (Binary Utilities)
Embedded Systems: Lecture 14: Introduction to GNU Toolchain (Binary Utilities)Embedded Systems: Lecture 14: Introduction to GNU Toolchain (Binary Utilities)
Embedded Systems: Lecture 14: Introduction to GNU Toolchain (Binary Utilities)
 
Hacking and Securing iOS Apps : Part 1
Hacking and Securing iOS Apps : Part 1Hacking and Securing iOS Apps : Part 1
Hacking and Securing iOS Apps : Part 1
 
Asp .net folders and web.config
Asp .net folders and web.configAsp .net folders and web.config
Asp .net folders and web.config
 
358 33 powerpoint-slides_16-files-their-organization_chapter-16
358 33 powerpoint-slides_16-files-their-organization_chapter-16358 33 powerpoint-slides_16-files-their-organization_chapter-16
358 33 powerpoint-slides_16-files-their-organization_chapter-16
 
Android datastorage
Android datastorageAndroid datastorage
Android datastorage
 
Android project architecture
Android project architectureAndroid project architecture
Android project architecture
 
Lab4 - android
Lab4 - androidLab4 - android
Lab4 - android
 
CNIT 121: 13 Investigating Mac OS X Systems
CNIT 121: 13 Investigating Mac OS X SystemsCNIT 121: 13 Investigating Mac OS X Systems
CNIT 121: 13 Investigating Mac OS X Systems
 
iOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for BeginnersiOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for Beginners
 
Windows Phone 8 - 4 Files and Storage
Windows Phone 8 - 4 Files and StorageWindows Phone 8 - 4 Files and Storage
Windows Phone 8 - 4 Files and Storage
 
Memory management
Memory managementMemory management
Memory management
 
Selecting And Protecting The Right Sharepoint Backup Targets Sps Michigan
Selecting And Protecting The Right Sharepoint Backup Targets Sps MichiganSelecting And Protecting The Right Sharepoint Backup Targets Sps Michigan
Selecting And Protecting The Right Sharepoint Backup Targets Sps Michigan
 
Mobile Application Development -Lecture 11 & 12.pdf
Mobile Application Development -Lecture 11 & 12.pdfMobile Application Development -Lecture 11 & 12.pdf
Mobile Application Development -Lecture 11 & 12.pdf
 
Armsec 2017 | 2 bugs 1 safari
Armsec 2017 | 2 bugs 1 safariArmsec 2017 | 2 bugs 1 safari
Armsec 2017 | 2 bugs 1 safari
 

More from Calvin Cheng

FOSSASIA 2018 Self-Sovereign Identity with Hyperledger Indy/Sovrin
FOSSASIA 2018 Self-Sovereign Identity with Hyperledger Indy/SovrinFOSSASIA 2018 Self-Sovereign Identity with Hyperledger Indy/Sovrin
FOSSASIA 2018 Self-Sovereign Identity with Hyperledger Indy/SovrinCalvin Cheng
 
So, you want to build a Bluetooth Low Energy device?
So, you want to build a Bluetooth Low Energy device?So, you want to build a Bluetooth Low Energy device?
So, you want to build a Bluetooth Low Energy device?Calvin Cheng
 
Django101 geodjango
Django101 geodjangoDjango101 geodjango
Django101 geodjangoCalvin Cheng
 
Saving Gaia with GeoDjango
Saving Gaia with GeoDjangoSaving Gaia with GeoDjango
Saving Gaia with GeoDjangoCalvin Cheng
 
Agile Apps with App Engine
Agile Apps with App EngineAgile Apps with App Engine
Agile Apps with App EngineCalvin Cheng
 

More from Calvin Cheng (9)

FOSSASIA 2018 Self-Sovereign Identity with Hyperledger Indy/Sovrin
FOSSASIA 2018 Self-Sovereign Identity with Hyperledger Indy/SovrinFOSSASIA 2018 Self-Sovereign Identity with Hyperledger Indy/Sovrin
FOSSASIA 2018 Self-Sovereign Identity with Hyperledger Indy/Sovrin
 
Hashgraph as Code
Hashgraph as CodeHashgraph as Code
Hashgraph as Code
 
So, you want to build a Bluetooth Low Energy device?
So, you want to build a Bluetooth Low Energy device?So, you want to build a Bluetooth Low Energy device?
So, you want to build a Bluetooth Low Energy device?
 
Fabric
FabricFabric
Fabric
 
Ladypy 01
Ladypy 01Ladypy 01
Ladypy 01
 
zhng your vim
zhng your vimzhng your vim
zhng your vim
 
Django101 geodjango
Django101 geodjangoDjango101 geodjango
Django101 geodjango
 
Saving Gaia with GeoDjango
Saving Gaia with GeoDjangoSaving Gaia with GeoDjango
Saving Gaia with GeoDjango
 
Agile Apps with App Engine
Agile Apps with App EngineAgile Apps with App Engine
Agile Apps with App Engine
 

Recently uploaded

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 

Recently uploaded (20)

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 

iOS Beginners Lesson 3

  • 2. OVERVIEW • Lesson 1: Introductions • Lesson 2: iOS specifics • Lesson 3: Data Model • Lesson 4: Logic (Controller) & Interface
  • 3. LESSON 3: DATA MODEL • Hour 1: Local Storage and Data Class • Hour 2: Dictionary and User Defaults • Hour 3: Save to File
  • 4. Local Storage and Data Class
  • 5. • Instantiating objects from classes (NSObject) keep your object’s data in your app/device memory • These data “disappears” when your app is shut down or if you shut down/reboot your phone • To persist your data for your user, you need “local storage” (i.e. data is written into our Local Storage?
  • 7. <Application Home>/AppName.app • Known as the bundle directory • Do not write anything into this directory • To prevent tampering, the bundle directory is signed at installation time • If you write into this directory after your app launches, your app cannot be launched again Commonly used directories for Storage
  • 8. <Application Home>/Documents/ • Store critical user documents and app data files • Critical data refers to any data that cannot be re- created by our app • Contents of this directory can be made available to user through file sharing • Contents of this directory are backed up by iTunes Commonly used directories for Storage
  • 9. <Application Home>/Documents/Inbox/ • Use this directory to access files that your app was asked to open by outside entities, e.g. Mail program • Your app can read and delete files in this directory but cannot create new files or write into existing files • If user needs to edit file in this directory, app must silently move it out of directory before making changes • Contents of this directory are backed up by iTunes Commonly used directories for Storage
  • 10. <Application Home>/Library/ • Non-user data files. This directory should not be used for user data files. Use it for your app support files. • The contents of this directory, except for the Caches subdirectory, are backed up by iTunes • iOS 5.0 & earlier, put app support files in <Application Home>/Library/Caches so these files don’t get backed up • iOS 5.0.1 and later, app support files go into <Application Home>/Library/Application Support directory and is applied with the com.apple.MobileBackup extended attribute to each support file so files do not get backed up to either iTunes or iCloud • If you have a lot of support files, store them all in a custom sub-directory and apply the extended attribute to that sub-directory • Data cache files are placed in <Application Home>/Library/Caches directory. Database cache files, downloadable content used by magazine, newspaper and map apps are also stored here. Your app needs to be able to gracefully handle situations where cached data is deleted by the system to free up disk space Commonly used directories for Storage
  • 11. <Application Home>/tmp/ • This directory is used to place data which we do not need to keep for extended periods of time • It’s a good habit to delete files in this tmp directory when we no longer need to use the file we have placed there temporarily. Commonly used directories for Storage
  • 12. • User Defaults (the ‘standard’ plist) • Different file types (PDFs, text, doc, images as png, jpg etc etc) • CoreData (SQLite database) • 3rd party solutions like Realm.io Options for Local Storage?
  • 13. User Defaults, also known as “Shared Preferences” • Key/value pairs • Managed through Objective-C • Stored in XML files that are managed through Apple’s API • Stored in unencrypted format (“plain text”) Options for Local Storage?
  • 14. File Storage • Files can be created and read on disk • No special file type, so store any file type that you like (XML, JSON, delimited data csv, PDF, png, jpg etc) • Store these files “internal to app” or “external to app” (in a shared file locations, such a Photo Albums) Options for Local Storage?
  • 15. SQLite and Core Data • Structured data with relationships can be saved into an SQLite database • iOS provides built-in support for SQLite (www.sqlite.org) • All classes and interfaces are in CoreData package • Database files are stored in “internal location” in app (within the app sandbox) Options for Local Storage?
  • 16. • We can use User Defaults • Each note can be represented as a key-value pair in User Defaults ‣ key: a unique date-time stamp ‣ value: string • Practical example: User defaults (NSUserDefaults) • Practical example: File Storage How do we store Notes?
  • 17. • Representation of what your app does (using custom classes, subclass from NSObject for example) • Spaceship game app will have Spaceship class, TakeNotes app will have Note class, Painting app could define a Image class • Can subclass from UIDocument as well if we want to define a document-based data model • Other possibilities if using CoreData (NSManagedObject) or Realm.io (RLMObject) Data model objects
  • 18. Create our “Data” class for Notes
  • 19. Create our “Data” class for Notes
  • 20. Create our “Data” class for Notes
  • 21. Create our “Data” class for Notes
  • 22. Create our “Data” class for Notes
  • 30. WHAT’S NEXT • Lesson 1: Introductions • Lesson 2: iOS specifics • Lesson 3: Data Model • Lesson 4: Logic (Controller) & Interface