SlideShare una empresa de Scribd logo
1 de 18
Mobile City: Core Data




       TaskList
About Me
●   Allan Davis
    –   Lead Developer of Mobile Technology for
        DealerMatch
    –   Cajun.code@gmail.com
    –   @cajun_code
Session Agenda
●   Introduction(Tip Calculator)
●   Overview of Objective C(TicTacToe)
●   UI UX (TrackerPoker)
●   CoreData (MyBloodyTaskList)
●   Networking and web-services
    (TrackerPokerLive)
●   Debugging, Testing, Tuning and Distribution
●   Game Development with Cocos2d (Oni Attack)
Class Agenda
●   What is CoreData
●   Create the Data Model
●   NSManagedObjectContext
●   UIManagedDocument
●   AppDelegate
●   Generate Object Models
●   Create
●   Read
●   Update
●   Delete
●   NSFetchedResultsController
What is Core Data
●   Object Relational Management tool.
●   How does it work?
    –   Create a visual mapping of database to objects
    –   Create query for objects using object-oriented API
    –   Access the “columns in the database table” using
        properties on the objects
Creating the Data Model
Create Model Visually
NSManagedObjectContext
●   Session Management object where all activity
    turns.
●   Two ways to create one.
    –   Create a UIManagedDocument and ask for the
        context
    –   Property off the AppDelegate if you selected “Use
        Core Data” when you created the project
UIManagedDocument
●     Create Property for UIManagedDocument
-   (void)useDocument
{
   if (![[NSFileManager defaultManager] fileExistsAtPath:[self.photoDatabase.fileURL path]]) {
       // does not exist on disk, so create it
       [self.photoDatabase saveToURL:self.photoDatabase.fileURL
forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success) {
           [self setupFetchedResultsController];
           [self fetchFlickrDataIntoDocument:self.photoDatabase];

        }];
     } else if (self.photoDatabase.documentState == UIDocumentStateClosed) {
        // exists on disk, but we need to open it
        [self.photoDatabase openWithCompletionHandler:^(BOOL success) {
            [self setupFetchedResultsController];
        }];
     } else if (self.photoDatabase.documentState == UIDocumentStateNormal) {
        // already open and ready to use
        [self setupFetchedResultsController];
     }
}
AppDelegate
●   Generated by Xcode
●   Need to push context down to down to
    ViewController

UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
UIViewController *controller = navigationController.topViewController;
[controller performSelector:@selector(setManagedObjectContext:) withObject:self.managedObjectContext];
Generate Classes from Model
Create
Trim *trim = [NSEntityDescription insertNewObjectForEntityForName:@"Trim"
                                          inManagedObjectContext:context];
Read
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription
                      entityForName:@"Task" inManagedObjectContext:context];
[fetchRequest setEntity:entity];
fetchRequest.predicate =
     [NSPredicate predicateWithFormat:@"category.name = %@", category.name];
fetchRequest.sortDescriptors =
     @[[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]];
[context executeFetchRequest:fetchRequest error:&error];
Update
●   Make changes to property
●   Call save on the ManagedObjectContext
Delete
●   Call delete on the ManagedObjectContext and
    pass in the object to delete
NSFetchRequestController
●   Adds functionality to monitor a FetchRequest
    to update a table view.
TaskList
●   Simple Task List
●   Sorted by Category
Resources
●   Stanford CS 193P
    –   Lecture 13 and 14 are Core Data
    –   http://www.stanford.edu/class/cs193p/cgi-bin/drupal/
●   Class Links
    –   Videos: http://vimeo.com/channels/mobilecity
    –   Slides: http://www.slideshare.net/javaalley/
    –   Code:
        https://github.com/organizations/AtlantaMobileDevGroup

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

BackboneJs
BackboneJsBackboneJs
BackboneJs
 
Introducing jQuery
Introducing jQueryIntroducing jQuery
Introducing jQuery
 
Javascript session june 2013 (iii) jquery json
Javascript session june 2013 (iii) jquery   jsonJavascript session june 2013 (iii) jquery   json
Javascript session june 2013 (iii) jquery json
 
Introducing AngularJS
Introducing AngularJSIntroducing AngularJS
Introducing AngularJS
 
Road to react hooks
Road to react hooksRoad to react hooks
Road to react hooks
 
20120121
2012012120120121
20120121
 
Dart and AngularDart
Dart and AngularDartDart and AngularDart
Dart and AngularDart
 
jQuery
jQueryjQuery
jQuery
 
Javascript - Beyond-jQuery
Javascript - Beyond-jQueryJavascript - Beyond-jQuery
Javascript - Beyond-jQuery
 
The next step, part 2
The next step, part 2The next step, part 2
The next step, part 2
 
JavaScript para Graficos y Visualizacion de Datos - BogotaJS
JavaScript para Graficos y Visualizacion de Datos - BogotaJSJavaScript para Graficos y Visualizacion de Datos - BogotaJS
JavaScript para Graficos y Visualizacion de Datos - BogotaJS
 
Magento Dependency Injection
Magento Dependency InjectionMagento Dependency Injection
Magento Dependency Injection
 
Backbone 4.0
Backbone 4.0Backbone 4.0
Backbone 4.0
 
Pengenalan blaast platform sdk
Pengenalan blaast platform sdkPengenalan blaast platform sdk
Pengenalan blaast platform sdk
 
Nodejs do teste de unidade ao de integração
Nodejs  do teste de unidade ao de integraçãoNodejs  do teste de unidade ao de integração
Nodejs do teste de unidade ao de integração
 
Building an Invisible App
Building an Invisible AppBuilding an Invisible App
Building an Invisible App
 
Backbone
BackboneBackbone
Backbone
 
Hack tutorial
Hack tutorialHack tutorial
Hack tutorial
 
Inicializacao win7
Inicializacao win7Inicializacao win7
Inicializacao win7
 
Magento2&java script (2)
Magento2&java script (2)Magento2&java script (2)
Magento2&java script (2)
 

Destacado

Mobilecity:Android Introduction
Mobilecity:Android IntroductionMobilecity:Android Introduction
Mobilecity:Android IntroductionAllan Davis
 
The Blue Jay by Kylie
The Blue Jay by KylieThe Blue Jay by Kylie
The Blue Jay by KyliePS99
 
Continuous Integration for IOS Apps
Continuous Integration for IOS AppsContinuous Integration for IOS Apps
Continuous Integration for IOS AppsAllan Davis
 
Composite Images Presentation
Composite Images PresentationComposite Images Presentation
Composite Images PresentationJames Brown
 
One Shot Short Introduction
One Shot Short IntroductionOne Shot Short Introduction
One Shot Short IntroductionJames Brown
 
CJUSD Instructional Coaching Model
CJUSD Instructional Coaching ModelCJUSD Instructional Coaching Model
CJUSD Instructional Coaching ModelJames Brown
 
The perfect shot
The perfect shotThe perfect shot
The perfect shotJames Brown
 
ICT Literacy Report and Plan
ICT Literacy Report and PlanICT Literacy Report and Plan
ICT Literacy Report and PlanJames Brown
 
Global Success Systems Service Catalogue Ver 1.0
Global Success Systems  Service Catalogue Ver 1.0Global Success Systems  Service Catalogue Ver 1.0
Global Success Systems Service Catalogue Ver 1.0Sreechith Radhakrishnan
 
Four Black Squares Design Concepts
Four Black Squares Design ConceptsFour Black Squares Design Concepts
Four Black Squares Design ConceptsJames Brown
 
Why people resist change? Presented @ ISACA UAE Chapter
Why people resist  change? Presented @ ISACA UAE ChapterWhy people resist  change? Presented @ ISACA UAE Chapter
Why people resist change? Presented @ ISACA UAE ChapterSreechith Radhakrishnan
 
Parts of a Script
Parts of a ScriptParts of a Script
Parts of a ScriptJames Brown
 

Destacado (18)

Mobilecity:Android Introduction
Mobilecity:Android IntroductionMobilecity:Android Introduction
Mobilecity:Android Introduction
 
The Blue Jay by Kylie
The Blue Jay by KylieThe Blue Jay by Kylie
The Blue Jay by Kylie
 
Continuous Integration for IOS Apps
Continuous Integration for IOS AppsContinuous Integration for IOS Apps
Continuous Integration for IOS Apps
 
Composite Images Presentation
Composite Images PresentationComposite Images Presentation
Composite Images Presentation
 
prueba
pruebaprueba
prueba
 
5 essential-facts-about-cobit
5 essential-facts-about-cobit5 essential-facts-about-cobit
5 essential-facts-about-cobit
 
Introduction to cobit 5.0
Introduction to cobit 5.0Introduction to cobit 5.0
Introduction to cobit 5.0
 
One Shot Short Introduction
One Shot Short IntroductionOne Shot Short Introduction
One Shot Short Introduction
 
Cloud Essentials - ISACA CPE Meeting
Cloud Essentials - ISACA CPE MeetingCloud Essentials - ISACA CPE Meeting
Cloud Essentials - ISACA CPE Meeting
 
How to improve your results - Webinar
How to improve your results - WebinarHow to improve your results - Webinar
How to improve your results - Webinar
 
CJUSD Instructional Coaching Model
CJUSD Instructional Coaching ModelCJUSD Instructional Coaching Model
CJUSD Instructional Coaching Model
 
The perfect shot
The perfect shotThe perfect shot
The perfect shot
 
Idea Mapping
Idea MappingIdea Mapping
Idea Mapping
 
ICT Literacy Report and Plan
ICT Literacy Report and PlanICT Literacy Report and Plan
ICT Literacy Report and Plan
 
Global Success Systems Service Catalogue Ver 1.0
Global Success Systems  Service Catalogue Ver 1.0Global Success Systems  Service Catalogue Ver 1.0
Global Success Systems Service Catalogue Ver 1.0
 
Four Black Squares Design Concepts
Four Black Squares Design ConceptsFour Black Squares Design Concepts
Four Black Squares Design Concepts
 
Why people resist change? Presented @ ISACA UAE Chapter
Why people resist  change? Presented @ ISACA UAE ChapterWhy people resist  change? Presented @ ISACA UAE Chapter
Why people resist change? Presented @ ISACA UAE Chapter
 
Parts of a Script
Parts of a ScriptParts of a Script
Parts of a Script
 

Similar a MobileCity:Core Data

iOSDevCamp 2011 Core Data
iOSDevCamp 2011 Core DataiOSDevCamp 2011 Core Data
iOSDevCamp 2011 Core DataChris Mar
 
Core Data with Swift 3.0
Core Data with Swift 3.0Core Data with Swift 3.0
Core Data with Swift 3.0Korhan Bircan
 
Nuxeo World Session: Layouts and Content Views
Nuxeo World Session: Layouts and Content ViewsNuxeo World Session: Layouts and Content Views
Nuxeo World Session: Layouts and Content ViewsNuxeo
 
Formacion en movilidad: Conceptos de desarrollo en iOS (IV)
Formacion en movilidad: Conceptos de desarrollo en iOS (IV) Formacion en movilidad: Conceptos de desarrollo en iOS (IV)
Formacion en movilidad: Conceptos de desarrollo en iOS (IV) Mobivery
 
Core Data with multiple managed object contexts
Core Data with multiple managed object contextsCore Data with multiple managed object contexts
Core Data with multiple managed object contextsMatthew Morey
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJsTudor Barbu
 
Surviving UI Automation Armageddon with BELLATRIX.pptx
Surviving UI Automation Armageddon with BELLATRIX.pptxSurviving UI Automation Armageddon with BELLATRIX.pptx
Surviving UI Automation Armageddon with BELLATRIX.pptxNikolayAvramov4
 
Beginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCABeginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCAWhymca
 
Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...
Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...
Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...Aaron Saunders
 
Architecture components, Константин Марс, TeamLead, Senior Developer, DataArt
Architecture components, Константин Марс, TeamLead, Senior Developer, DataArtArchitecture components, Константин Марс, TeamLead, Senior Developer, DataArt
Architecture components, Константин Марс, TeamLead, Senior Developer, DataArtAlina Vilk
 
iOS Beginners Lesson 4
iOS Beginners Lesson 4iOS Beginners Lesson 4
iOS Beginners Lesson 4Calvin Cheng
 
Building Apps with Flutter - Hillel Coren, Invoice Ninja
Building Apps with Flutter - Hillel Coren, Invoice NinjaBuilding Apps with Flutter - Hillel Coren, Invoice Ninja
Building Apps with Flutter - Hillel Coren, Invoice NinjaDroidConTLV
 
OpenCms Days 2014 - User Generated Content in OpenCms 9.5
OpenCms Days 2014 - User Generated Content in OpenCms 9.5OpenCms Days 2014 - User Generated Content in OpenCms 9.5
OpenCms Days 2014 - User Generated Content in OpenCms 9.5Alkacon Software GmbH & Co. KG
 
Intro to Core Data
Intro to Core DataIntro to Core Data
Intro to Core DataMake School
 
Magento Performance Toolkit
Magento Performance ToolkitMagento Performance Toolkit
Magento Performance ToolkitSergii Shymko
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest servicesIoan Eugen Stan
 

Similar a MobileCity:Core Data (20)

iOSDevCamp 2011 Core Data
iOSDevCamp 2011 Core DataiOSDevCamp 2011 Core Data
iOSDevCamp 2011 Core Data
 
Core Data with Swift 3.0
Core Data with Swift 3.0Core Data with Swift 3.0
Core Data with Swift 3.0
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Nuxeo World Session: Layouts and Content Views
Nuxeo World Session: Layouts and Content ViewsNuxeo World Session: Layouts and Content Views
Nuxeo World Session: Layouts and Content Views
 
Formacion en movilidad: Conceptos de desarrollo en iOS (IV)
Formacion en movilidad: Conceptos de desarrollo en iOS (IV) Formacion en movilidad: Conceptos de desarrollo en iOS (IV)
Formacion en movilidad: Conceptos de desarrollo en iOS (IV)
 
Core Data with multiple managed object contexts
Core Data with multiple managed object contextsCore Data with multiple managed object contexts
Core Data with multiple managed object contexts
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJs
 
Surviving UI Automation Armageddon with BELLATRIX.pptx
Surviving UI Automation Armageddon with BELLATRIX.pptxSurviving UI Automation Armageddon with BELLATRIX.pptx
Surviving UI Automation Armageddon with BELLATRIX.pptx
 
Beginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCABeginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCA
 
Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...
Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...
Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...
 
Architecture components, Константин Марс, TeamLead, Senior Developer, DataArt
Architecture components, Константин Марс, TeamLead, Senior Developer, DataArtArchitecture components, Константин Марс, TeamLead, Senior Developer, DataArt
Architecture components, Константин Марс, TeamLead, Senior Developer, DataArt
 
iOS Beginners Lesson 4
iOS Beginners Lesson 4iOS Beginners Lesson 4
iOS Beginners Lesson 4
 
Building Apps with Flutter - Hillel Coren, Invoice Ninja
Building Apps with Flutter - Hillel Coren, Invoice NinjaBuilding Apps with Flutter - Hillel Coren, Invoice Ninja
Building Apps with Flutter - Hillel Coren, Invoice Ninja
 
OpenCms Days 2014 - User Generated Content in OpenCms 9.5
OpenCms Days 2014 - User Generated Content in OpenCms 9.5OpenCms Days 2014 - User Generated Content in OpenCms 9.5
OpenCms Days 2014 - User Generated Content in OpenCms 9.5
 
WOdka
WOdkaWOdka
WOdka
 
iOS
iOSiOS
iOS
 
Intro to Core Data
Intro to Core DataIntro to Core Data
Intro to Core Data
 
201104 iphone navigation-based apps
201104 iphone navigation-based apps201104 iphone navigation-based apps
201104 iphone navigation-based apps
 
Magento Performance Toolkit
Magento Performance ToolkitMagento Performance Toolkit
Magento Performance Toolkit
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest services
 

Más de Allan Davis

Flutter game development
Flutter game developmentFlutter game development
Flutter game developmentAllan Davis
 
Vr unity cardboard
Vr unity cardboardVr unity cardboard
Vr unity cardboardAllan Davis
 
Cross Platform Mobile Game Development
Cross Platform Mobile Game DevelopmentCross Platform Mobile Game Development
Cross Platform Mobile Game DevelopmentAllan Davis
 
MobileCity: UI UX Design
MobileCity: UI UX DesignMobileCity: UI UX Design
MobileCity: UI UX DesignAllan Davis
 
Coocoo for Cocoapods
Coocoo for CocoapodsCoocoo for Cocoapods
Coocoo for CocoapodsAllan Davis
 
MobileCity: Overview of ObjectiveC
MobileCity: Overview of ObjectiveCMobileCity: Overview of ObjectiveC
MobileCity: Overview of ObjectiveCAllan Davis
 
MobileCity:Introduction to IOS
MobileCity:Introduction to IOSMobileCity:Introduction to IOS
MobileCity:Introduction to IOSAllan Davis
 

Más de Allan Davis (9)

Flutter game development
Flutter game developmentFlutter game development
Flutter game development
 
Vr unity cardboard
Vr unity cardboardVr unity cardboard
Vr unity cardboard
 
Cross Platform Mobile Game Development
Cross Platform Mobile Game DevelopmentCross Platform Mobile Game Development
Cross Platform Mobile Game Development
 
MobileCity: UI UX Design
MobileCity: UI UX DesignMobileCity: UI UX Design
MobileCity: UI UX Design
 
Coocoo for Cocoapods
Coocoo for CocoapodsCoocoo for Cocoapods
Coocoo for Cocoapods
 
MobileCity: Overview of ObjectiveC
MobileCity: Overview of ObjectiveCMobileCity: Overview of ObjectiveC
MobileCity: Overview of ObjectiveC
 
MobileCity:Introduction to IOS
MobileCity:Introduction to IOSMobileCity:Introduction to IOS
MobileCity:Introduction to IOS
 
Generators
GeneratorsGenerators
Generators
 
Django agenda
Django agendaDjango agenda
Django agenda
 

MobileCity:Core Data

  • 1. Mobile City: Core Data TaskList
  • 2. About Me ● Allan Davis – Lead Developer of Mobile Technology for DealerMatch – Cajun.code@gmail.com – @cajun_code
  • 3. Session Agenda ● Introduction(Tip Calculator) ● Overview of Objective C(TicTacToe) ● UI UX (TrackerPoker) ● CoreData (MyBloodyTaskList) ● Networking and web-services (TrackerPokerLive) ● Debugging, Testing, Tuning and Distribution ● Game Development with Cocos2d (Oni Attack)
  • 4. Class Agenda ● What is CoreData ● Create the Data Model ● NSManagedObjectContext ● UIManagedDocument ● AppDelegate ● Generate Object Models ● Create ● Read ● Update ● Delete ● NSFetchedResultsController
  • 5. What is Core Data ● Object Relational Management tool. ● How does it work? – Create a visual mapping of database to objects – Create query for objects using object-oriented API – Access the “columns in the database table” using properties on the objects
  • 8. NSManagedObjectContext ● Session Management object where all activity turns. ● Two ways to create one. – Create a UIManagedDocument and ask for the context – Property off the AppDelegate if you selected “Use Core Data” when you created the project
  • 9. UIManagedDocument ● Create Property for UIManagedDocument - (void)useDocument { if (![[NSFileManager defaultManager] fileExistsAtPath:[self.photoDatabase.fileURL path]]) { // does not exist on disk, so create it [self.photoDatabase saveToURL:self.photoDatabase.fileURL forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success) { [self setupFetchedResultsController]; [self fetchFlickrDataIntoDocument:self.photoDatabase]; }]; } else if (self.photoDatabase.documentState == UIDocumentStateClosed) { // exists on disk, but we need to open it [self.photoDatabase openWithCompletionHandler:^(BOOL success) { [self setupFetchedResultsController]; }]; } else if (self.photoDatabase.documentState == UIDocumentStateNormal) { // already open and ready to use [self setupFetchedResultsController]; } }
  • 10. AppDelegate ● Generated by Xcode ● Need to push context down to down to ViewController UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController; UIViewController *controller = navigationController.topViewController; [controller performSelector:@selector(setManagedObjectContext:) withObject:self.managedObjectContext];
  • 12. Create Trim *trim = [NSEntityDescription insertNewObjectForEntityForName:@"Trim" inManagedObjectContext:context];
  • 13. Read NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Task" inManagedObjectContext:context]; [fetchRequest setEntity:entity]; fetchRequest.predicate = [NSPredicate predicateWithFormat:@"category.name = %@", category.name]; fetchRequest.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]]; [context executeFetchRequest:fetchRequest error:&error];
  • 14. Update ● Make changes to property ● Call save on the ManagedObjectContext
  • 15. Delete ● Call delete on the ManagedObjectContext and pass in the object to delete
  • 16. NSFetchRequestController ● Adds functionality to monitor a FetchRequest to update a table view.
  • 17. TaskList ● Simple Task List ● Sorted by Category
  • 18. Resources ● Stanford CS 193P – Lecture 13 and 14 are Core Data – http://www.stanford.edu/class/cs193p/cgi-bin/drupal/ ● Class Links – Videos: http://vimeo.com/channels/mobilecity – Slides: http://www.slideshare.net/javaalley/ – Code: https://github.com/organizations/AtlantaMobileDevGroup