SlideShare ist ein Scribd-Unternehmen logo
1 von 30
Downloaden Sie, um offline zu lesen
LOGIC & INTERFACE 
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: Storyboard 
• Hour 2: Creating & Editing 
• Hour 3: Display & Deleting Notes
Storyboard
Storyboard
Storyboard 
• Visual representation of iOS user interface (UI) 
• Shows screens of content and connections 
between screens. Screens referred to as 
“Scene” 
• 1 “Scene” represents 1 View Controller and 
Views 
• Many “views” can be placed on 1 “scene” (e.g. 
buttons, table views, text views). Think of views
Storyboard 
• Each scene has a dock (displays icons 
representing the top-level objects of the 
scene)
Storyboard 
• The “dock” is where we make connections 
between code in our View Controller and its 
Views (“visual objects on the scene”)
View Controllers 
• A storyboard displays View Controllers and 
corresponding Views visually
View Controllers 
• A storyboard displays View Controllers and 
corresponding Views visually
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
// Override point for customization after application launch. 
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { 
UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController; 
UINavigationController *navigationController = [splitViewController.viewControllers lastObject]; 
splitViewController.delegate = (id)navigationController.topViewController; 
} 
return YES; 
} 
View Controllers
View Controllers
View Controllers 
UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
View Controllers 
UINavigationController 
• Sub-class of UIViewController 
• a special View Controller that manages the navigation of 
hierarchical content
View Controllers 
UINavigationController 
• It is a “container” that embeds content of other View 
Controllers inside itself
Creating and Editing
View Controllers 
AppDelegate.m 
#import "AppDelegate.h" 
#import "Data.h" 
@implementation AppDelegate 
- (BOOL)application:(UIApplication *)application 
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
[Data getAllNotes]; 
return YES; 
}
View Controllers 
MasterViewController.m 
#import “Data.h" 
- (void)insertNewObject:(id)sender 
{ 
if (!_objects) { 
_objects = [[NSMutableArray alloc] init]; 
} 
//[_objects insertObject:[NSDate date] atIndex:0]; 
NSString *key = [[NSDate date] description]; 
[Data setNote:kDefaultText forKey:key]; 
[Data setCurrentKey:key]; 
[_objects insertObject:key atIndex:0]; 
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0]; 
[self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; 
}
View Controllers 
DetailViewController.m 
#import “Data.h" 
- (void)setDetailItem:(id)newDetailItem 
{ 
if (_detailItem != newDetailItem) { 
_detailItem = newDetailItem; 
[Data setCurrentKey:_detailItem]; 
// Update the view. 
[self configureView]; 
} 
if (self.masterPopoverController != nil) { 
[self.masterPopoverController dismissPopoverAnimated:YES]; 
} 
}
View Controllers 
DetailViewController.m 
- (void)configureView 
{ 
NSString *currentNote = [[Data getAllNotes] objectForKey:[Data getCurrentKey]]; 
if (![currentNote isEqualToString:kDefaultText]) { 
self.tView.text = currentNote; 
} else { 
self.tView.text = @""; 
} 
[self.tView becomeFirstResponder]; 
}
View Controllers 
DetailViewController.m 
- (void)viewWillDisappear:(BOOL)animated 
{ 
if (![self.tView.text isEqualToString:@""]) { 
[Data setNoteForCurrentKey:self.tView.text]; 
} else { 
[Data removeNoteForKey:[Data getCurrentKey]]; 
} 
[Data saveNotes]; 
}
Displaying & Deleting
View Controllers 
MasterViewController.m 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath 
*)indexPath 
{ 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" 
forIndexPath:indexPath]; 
NSDate *object = _objects[indexPath.row]; 
cell.textLabel.text = [[Data getAllNotes] objectForKey:[object description]]; 
return cell; 
}
View Controllers 
MasterViewController.m 
- (void)makeObjects 
{ 
_objects = [NSMutableArray arrayWithArray:[[Data getAllNotes] allKeys]]; 
[_objects sortUsingComparator:^NSComparisonResult(id obj1, id obj2) { 
return [(NSDate *)obj2 compare:(NSDate *)obj1]; 
}]; 
}
View Controllers 
MasterViewController.m 
- (void)insertNewObject:(id)sender 
{ 
[self makeObjects]; 
if (!_objects) { 
_objects = [[NSMutableArray alloc] init]; 
} 
//[_objects insertObject:[NSDate date] atIndex:0]; 
NSString *key = [[NSDate date] description]; 
[Data setNote:kDefaultText forKey:key]; 
[Data setCurrentKey:key]; 
[_objects insertObject:key atIndex:0]; 
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0]; 
[self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; 
[self performSegueWithIdentifier:kDetailView sender:self]; 
}
View Controllers 
MasterViewController.m
View Controllers 
MasterViewController.m 
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { 
NSDate *object = _objects[indexPath.row]; 
self.detailViewController.detailItem = object; 
} 
} 
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{ 
if ([[segue identifier] isEqualToString:@"showDetail"]) { 
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; 
NSDate *object = _objects[indexPath.row]; 
[[segue destinationViewController] setDetailItem:object]; 
} 
}
View Controllers 
MasterViewController.m 
- (void)viewWillAppear:(BOOL)animated 
{ 
[super viewDidAppear:animated]; 
[self makeObjects]; 
[self.tableView reloadData]; 
}
View Controllers 
MasterViewController.m 
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
if (editingStyle == UITableViewCellEditingStyleDelete) { 
[Data removeNoteForKey:[_objects objectAtIndex:indexPath.row]]; 
[Data saveNotes]; 
[_objects removeObjectAtIndex:indexPath.row]; 
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; 
} else if (editingStyle == UITableViewCellEditingStyleInsert) { 
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table 
view. 
} 
}
OVERVIEW 
• Lesson 1: Introductions 
• Lesson 2: iOS specifics 
• Lesson 3: Data Model 
• Lesson 4: Logic (Controller) & Interface

Weitere ähnliche Inhalte

Was ist angesagt?

Programming Google apps with the G Suite APIs
Programming Google apps with the G Suite APIsProgramming Google apps with the G Suite APIs
Programming Google apps with the G Suite APIsDevFest DC
 
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 - BogotaJSphilogb
 
Functional Reactive Programming - RxSwift
Functional Reactive Programming - RxSwiftFunctional Reactive Programming - RxSwift
Functional Reactive Programming - RxSwiftRodrigo Leite
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY GOKUL SREE
 
Object Oriented Programing in JavaScript
Object Oriented Programing in JavaScriptObject Oriented Programing in JavaScript
Object Oriented Programing in JavaScriptAkshay Mathur
 
iOS State Preservation and Restoration
iOS State Preservation and RestorationiOS State Preservation and Restoration
iOS State Preservation and RestorationRobert Brown
 
Wix Automation - DIY - Testing BI Events
Wix Automation - DIY - Testing BI EventsWix Automation - DIY - Testing BI Events
Wix Automation - DIY - Testing BI EventsEfrat Attas
 
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
 
iOSDevCamp 2011 Core Data
iOSDevCamp 2011 Core DataiOSDevCamp 2011 Core Data
iOSDevCamp 2011 Core DataChris Mar
 
Mobile Developers Talks: Delve Mobile
Mobile Developers Talks: Delve MobileMobile Developers Talks: Delve Mobile
Mobile Developers Talks: Delve MobileKonstantin Loginov
 
The next step, part 2
The next step, part 2The next step, part 2
The next step, part 2Pat Cavit
 
Asynchronous programming
Asynchronous programmingAsynchronous programming
Asynchronous programmingFilip Ekberg
 
No More Deadlocks; Asynchronous Programming in .NET
No More Deadlocks; Asynchronous Programming in .NETNo More Deadlocks; Asynchronous Programming in .NET
No More Deadlocks; Asynchronous Programming in .NETFilip Ekberg
 
[4developers] The saga pattern v3- Robert Pankowiecki
[4developers] The saga pattern v3- Robert Pankowiecki[4developers] The saga pattern v3- Robert Pankowiecki
[4developers] The saga pattern v3- Robert PankowieckiPROIDEA
 
Intorduction of Playframework
Intorduction of PlayframeworkIntorduction of Playframework
Intorduction of Playframeworkmaltiyadav
 
Cnam azure 2014 mobile services
Cnam azure 2014   mobile servicesCnam azure 2014   mobile services
Cnam azure 2014 mobile servicesAymeric Weinbach
 
2 years after the first event - The Saga Pattern
2 years after the first event - The Saga Pattern2 years after the first event - The Saga Pattern
2 years after the first event - The Saga PatternRobert Pankowecki
 
Reactive Programming Patterns with RxSwift
Reactive Programming Patterns with RxSwiftReactive Programming Patterns with RxSwift
Reactive Programming Patterns with RxSwiftFlorent Pillet
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginnersDivakar Gu
 

Was ist angesagt? (20)

Programming Google apps with the G Suite APIs
Programming Google apps with the G Suite APIsProgramming Google apps with the G Suite APIs
Programming Google apps with the G Suite APIs
 
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
 
Functional Reactive Programming - RxSwift
Functional Reactive Programming - RxSwiftFunctional Reactive Programming - RxSwift
Functional Reactive Programming - RxSwift
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
 
Object Oriented Programing in JavaScript
Object Oriented Programing in JavaScriptObject Oriented Programing in JavaScript
Object Oriented Programing in JavaScript
 
iOS State Preservation and Restoration
iOS State Preservation and RestorationiOS State Preservation and Restoration
iOS State Preservation and Restoration
 
Goa tutorial
Goa tutorialGoa tutorial
Goa tutorial
 
Wix Automation - DIY - Testing BI Events
Wix Automation - DIY - Testing BI EventsWix Automation - DIY - Testing BI Events
Wix Automation - DIY - Testing BI Events
 
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)
 
iOSDevCamp 2011 Core Data
iOSDevCamp 2011 Core DataiOSDevCamp 2011 Core Data
iOSDevCamp 2011 Core Data
 
Mobile Developers Talks: Delve Mobile
Mobile Developers Talks: Delve MobileMobile Developers Talks: Delve Mobile
Mobile Developers Talks: Delve Mobile
 
The next step, part 2
The next step, part 2The next step, part 2
The next step, part 2
 
Asynchronous programming
Asynchronous programmingAsynchronous programming
Asynchronous programming
 
No More Deadlocks; Asynchronous Programming in .NET
No More Deadlocks; Asynchronous Programming in .NETNo More Deadlocks; Asynchronous Programming in .NET
No More Deadlocks; Asynchronous Programming in .NET
 
[4developers] The saga pattern v3- Robert Pankowiecki
[4developers] The saga pattern v3- Robert Pankowiecki[4developers] The saga pattern v3- Robert Pankowiecki
[4developers] The saga pattern v3- Robert Pankowiecki
 
Intorduction of Playframework
Intorduction of PlayframeworkIntorduction of Playframework
Intorduction of Playframework
 
Cnam azure 2014 mobile services
Cnam azure 2014   mobile servicesCnam azure 2014   mobile services
Cnam azure 2014 mobile services
 
2 years after the first event - The Saga Pattern
2 years after the first event - The Saga Pattern2 years after the first event - The Saga Pattern
2 years after the first event - The Saga Pattern
 
Reactive Programming Patterns with RxSwift
Reactive Programming Patterns with RxSwiftReactive Programming Patterns with RxSwift
Reactive Programming Patterns with RxSwift
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 

Andere mochten auch

とりあえず使う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
 
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.
 
iOS Beginners Lesson 3
iOS Beginners Lesson 3iOS Beginners Lesson 3
iOS Beginners Lesson 3Calvin Cheng
 
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
 

Andere mochten auch (6)

とりあえず使う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?
 
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
 
iOS Beginners Lesson 3
iOS Beginners Lesson 3iOS Beginners Lesson 3
iOS Beginners Lesson 3
 
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)
 

Ähnlich wie iOS Beginners Lesson 4

Developing iOS REST Applications
Developing iOS REST ApplicationsDeveloping iOS REST Applications
Developing iOS REST Applicationslmrei
 
10 tips for a reusable architecture
10 tips for a reusable architecture10 tips for a reusable architecture
10 tips for a reusable architectureJorge Ortiz
 
MobileCity:Core Data
MobileCity:Core DataMobileCity:Core Data
MobileCity:Core DataAllan Davis
 
Formacion en movilidad: Conceptos de desarrollo en iOS (III)
Formacion en movilidad: Conceptos de desarrollo en iOS (III) Formacion en movilidad: Conceptos de desarrollo en iOS (III)
Formacion en movilidad: Conceptos de desarrollo en iOS (III) Mobivery
 
Your Second iPhone App - Code Listings
Your Second iPhone App - Code ListingsYour Second iPhone App - Code Listings
Your Second iPhone App - Code ListingsVu Tran Lam
 
iOS for ERREST - alternative version
iOS for ERREST - alternative versioniOS for ERREST - alternative version
iOS for ERREST - alternative versionWO Community
 
iOS Beginners Lesson 2
iOS Beginners Lesson 2iOS Beginners Lesson 2
iOS Beginners Lesson 2Calvin Cheng
 
iOS Development: What's New
iOS Development: What's NewiOS Development: What's New
iOS Development: What's NewNascentDigital
 
iOS 101 - Xcode, Objective-C, iOS APIs
iOS 101 - Xcode, Objective-C, iOS APIsiOS 101 - Xcode, Objective-C, iOS APIs
iOS 101 - Xcode, Objective-C, iOS APIsSubhransu Behera
 
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろうUnity Technologies Japan K.K.
 
EclipseCon2011 Cross-Platform Mobile Development with Eclipse
EclipseCon2011 Cross-Platform Mobile Development with EclipseEclipseCon2011 Cross-Platform Mobile Development with Eclipse
EclipseCon2011 Cross-Platform Mobile Development with EclipseHeiko Behrens
 
iOS Einführung am Beispiel von play NEXT TEE
iOS Einführung am Beispiel von play NEXT TEEiOS Einführung am Beispiel von play NEXT TEE
iOS Einführung am Beispiel von play NEXT TEEHendrik Ebel
 
Beginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCABeginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCAWhymca
 
Apple Templates Considered Harmful
Apple Templates Considered HarmfulApple Templates Considered Harmful
Apple Templates Considered HarmfulBrian Gesiak
 

Ähnlich wie iOS Beginners Lesson 4 (20)

iOS
iOSiOS
iOS
 
I os 11
I os 11I os 11
I os 11
 
Developing iOS REST Applications
Developing iOS REST ApplicationsDeveloping iOS REST Applications
Developing iOS REST Applications
 
10 tips for a reusable architecture
10 tips for a reusable architecture10 tips for a reusable architecture
10 tips for a reusable architecture
 
201104 iphone navigation-based apps
201104 iphone navigation-based apps201104 iphone navigation-based apps
201104 iphone navigation-based apps
 
MobileCity:Core Data
MobileCity:Core DataMobileCity:Core Data
MobileCity:Core Data
 
Formacion en movilidad: Conceptos de desarrollo en iOS (III)
Formacion en movilidad: Conceptos de desarrollo en iOS (III) Formacion en movilidad: Conceptos de desarrollo en iOS (III)
Formacion en movilidad: Conceptos de desarrollo en iOS (III)
 
Your Second iPhone App - Code Listings
Your Second iPhone App - Code ListingsYour Second iPhone App - Code Listings
Your Second iPhone App - Code Listings
 
iOS testing
iOS testingiOS testing
iOS testing
 
iOS for ERREST - alternative version
iOS for ERREST - alternative versioniOS for ERREST - alternative version
iOS for ERREST - alternative version
 
iOS Beginners Lesson 2
iOS Beginners Lesson 2iOS Beginners Lesson 2
iOS Beginners Lesson 2
 
For mobile 5/13'
For mobile 5/13'For mobile 5/13'
For mobile 5/13'
 
iOS 7 SDK特訓班
iOS 7 SDK特訓班iOS 7 SDK特訓班
iOS 7 SDK特訓班
 
iOS Development: What's New
iOS Development: What's NewiOS Development: What's New
iOS Development: What's New
 
iOS 101 - Xcode, Objective-C, iOS APIs
iOS 101 - Xcode, Objective-C, iOS APIsiOS 101 - Xcode, Objective-C, iOS APIs
iOS 101 - Xcode, Objective-C, iOS APIs
 
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
 
EclipseCon2011 Cross-Platform Mobile Development with Eclipse
EclipseCon2011 Cross-Platform Mobile Development with EclipseEclipseCon2011 Cross-Platform Mobile Development with Eclipse
EclipseCon2011 Cross-Platform Mobile Development with Eclipse
 
iOS Einführung am Beispiel von play NEXT TEE
iOS Einführung am Beispiel von play NEXT TEEiOS Einführung am Beispiel von play NEXT TEE
iOS Einführung am Beispiel von play NEXT TEE
 
Beginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCABeginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCA
 
Apple Templates Considered Harmful
Apple Templates Considered HarmfulApple Templates Considered Harmful
Apple Templates Considered Harmful
 

Mehr von 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
 
iOS Beginners Lesson 1
iOS Beginners Lesson 1iOS Beginners Lesson 1
iOS Beginners Lesson 1Calvin 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
 
Learning iOS and hunting NSZombies in 3 weeks
Learning iOS and hunting NSZombies in 3 weeksLearning iOS and hunting NSZombies in 3 weeks
Learning iOS and hunting NSZombies in 3 weeksCalvin 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
 

Mehr von Calvin Cheng (11)

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
 
iOS Beginners Lesson 1
iOS Beginners Lesson 1iOS Beginners Lesson 1
iOS Beginners Lesson 1
 
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
 
Learning iOS and hunting NSZombies in 3 weeks
Learning iOS and hunting NSZombies in 3 weeksLearning iOS and hunting NSZombies in 3 weeks
Learning iOS and hunting NSZombies in 3 weeks
 
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
 

Kürzlich hochgeladen

Fields in Java and Kotlin and what to expect.pptx
Fields in Java and Kotlin and what to expect.pptxFields in Java and Kotlin and what to expect.pptx
Fields in Java and Kotlin and what to expect.pptxJoão Esperancinha
 
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...OnePlan Solutions
 
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLBig Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLAlluxio, Inc.
 
OpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorOpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorShane Coughlan
 
Kawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in TrivandrumKawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in TrivandrumKawika Technologies
 
Your Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software TeamsYour Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software TeamsJaydeep Chhasatia
 
ERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxAutus Cyber Tech
 
JS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIJS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIIvo Andreev
 
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Jaydeep Chhasatia
 
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdfARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdfTobias Schneck
 
Top Software Development Trends in 2024
Top Software Development Trends in  2024Top Software Development Trends in  2024
Top Software Development Trends in 2024Mind IT Systems
 
IA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeIA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeNeo4j
 
Webinar_050417_LeClair12345666777889.ppt
Webinar_050417_LeClair12345666777889.pptWebinar_050417_LeClair12345666777889.ppt
Webinar_050417_LeClair12345666777889.pptkinjal48
 
Generative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilGenerative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilVICTOR MAESTRE RAMIREZ
 
Sales Territory Management: A Definitive Guide to Expand Sales Coverage
Sales Territory Management: A Definitive Guide to Expand Sales CoverageSales Territory Management: A Definitive Guide to Expand Sales Coverage
Sales Territory Management: A Definitive Guide to Expand Sales CoverageDista
 
Why Choose Brain Inventory For Ecommerce Development.pdf
Why Choose Brain Inventory For Ecommerce Development.pdfWhy Choose Brain Inventory For Ecommerce Development.pdf
Why Choose Brain Inventory For Ecommerce Development.pdfBrain Inventory
 
Streamlining Your Application Builds with Cloud Native Buildpacks
Streamlining Your Application Builds  with Cloud Native BuildpacksStreamlining Your Application Builds  with Cloud Native Buildpacks
Streamlining Your Application Builds with Cloud Native BuildpacksVish Abrams
 
Growing Oxen: channel operators and retries
Growing Oxen: channel operators and retriesGrowing Oxen: channel operators and retries
Growing Oxen: channel operators and retriesSoftwareMill
 
Deep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampDeep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampVICTOR MAESTRE RAMIREZ
 

Kürzlich hochgeladen (20)

Fields in Java and Kotlin and what to expect.pptx
Fields in Java and Kotlin and what to expect.pptxFields in Java and Kotlin and what to expect.pptx
Fields in Java and Kotlin and what to expect.pptx
 
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
 
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLBig Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
 
OpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorOpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS Calculator
 
Kawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in TrivandrumKawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in Trivandrum
 
Your Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software TeamsYour Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
 
Salesforce AI Associate Certification.pptx
Salesforce AI Associate Certification.pptxSalesforce AI Associate Certification.pptx
Salesforce AI Associate Certification.pptx
 
ERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptxERP For Electrical and Electronics manufecturing.pptx
ERP For Electrical and Electronics manufecturing.pptx
 
JS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIJS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AI
 
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
 
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdfARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
 
Top Software Development Trends in 2024
Top Software Development Trends in  2024Top Software Development Trends in  2024
Top Software Development Trends in 2024
 
IA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeIA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG time
 
Webinar_050417_LeClair12345666777889.ppt
Webinar_050417_LeClair12345666777889.pptWebinar_050417_LeClair12345666777889.ppt
Webinar_050417_LeClair12345666777889.ppt
 
Generative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-CouncilGenerative AI for Cybersecurity - EC-Council
Generative AI for Cybersecurity - EC-Council
 
Sales Territory Management: A Definitive Guide to Expand Sales Coverage
Sales Territory Management: A Definitive Guide to Expand Sales CoverageSales Territory Management: A Definitive Guide to Expand Sales Coverage
Sales Territory Management: A Definitive Guide to Expand Sales Coverage
 
Why Choose Brain Inventory For Ecommerce Development.pdf
Why Choose Brain Inventory For Ecommerce Development.pdfWhy Choose Brain Inventory For Ecommerce Development.pdf
Why Choose Brain Inventory For Ecommerce Development.pdf
 
Streamlining Your Application Builds with Cloud Native Buildpacks
Streamlining Your Application Builds  with Cloud Native BuildpacksStreamlining Your Application Builds  with Cloud Native Buildpacks
Streamlining Your Application Builds with Cloud Native Buildpacks
 
Growing Oxen: channel operators and retries
Growing Oxen: channel operators and retriesGrowing Oxen: channel operators and retries
Growing Oxen: channel operators and retries
 
Deep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampDeep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - Datacamp
 

iOS Beginners Lesson 4

  • 1. LOGIC & INTERFACE Building our App
  • 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: Storyboard • Hour 2: Creating & Editing • Hour 3: Display & Deleting Notes
  • 6. Storyboard • Visual representation of iOS user interface (UI) • Shows screens of content and connections between screens. Screens referred to as “Scene” • 1 “Scene” represents 1 View Controller and Views • Many “views” can be placed on 1 “scene” (e.g. buttons, table views, text views). Think of views
  • 7. Storyboard • Each scene has a dock (displays icons representing the top-level objects of the scene)
  • 8. Storyboard • The “dock” is where we make connections between code in our View Controller and its Views (“visual objects on the scene”)
  • 9. View Controllers • A storyboard displays View Controllers and corresponding Views visually
  • 10. View Controllers • A storyboard displays View Controllers and corresponding Views visually
  • 11. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController; UINavigationController *navigationController = [splitViewController.viewControllers lastObject]; splitViewController.delegate = (id)navigationController.topViewController; } return YES; } View Controllers
  • 13. View Controllers UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
  • 14. View Controllers UINavigationController • Sub-class of UIViewController • a special View Controller that manages the navigation of hierarchical content
  • 15. View Controllers UINavigationController • It is a “container” that embeds content of other View Controllers inside itself
  • 17. View Controllers AppDelegate.m #import "AppDelegate.h" #import "Data.h" @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [Data getAllNotes]; return YES; }
  • 18. View Controllers MasterViewController.m #import “Data.h" - (void)insertNewObject:(id)sender { if (!_objects) { _objects = [[NSMutableArray alloc] init]; } //[_objects insertObject:[NSDate date] atIndex:0]; NSString *key = [[NSDate date] description]; [Data setNote:kDefaultText forKey:key]; [Data setCurrentKey:key]; [_objects insertObject:key atIndex:0]; NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0]; [self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; }
  • 19. View Controllers DetailViewController.m #import “Data.h" - (void)setDetailItem:(id)newDetailItem { if (_detailItem != newDetailItem) { _detailItem = newDetailItem; [Data setCurrentKey:_detailItem]; // Update the view. [self configureView]; } if (self.masterPopoverController != nil) { [self.masterPopoverController dismissPopoverAnimated:YES]; } }
  • 20. View Controllers DetailViewController.m - (void)configureView { NSString *currentNote = [[Data getAllNotes] objectForKey:[Data getCurrentKey]]; if (![currentNote isEqualToString:kDefaultText]) { self.tView.text = currentNote; } else { self.tView.text = @""; } [self.tView becomeFirstResponder]; }
  • 21. View Controllers DetailViewController.m - (void)viewWillDisappear:(BOOL)animated { if (![self.tView.text isEqualToString:@""]) { [Data setNoteForCurrentKey:self.tView.text]; } else { [Data removeNoteForKey:[Data getCurrentKey]]; } [Data saveNotes]; }
  • 23. View Controllers MasterViewController.m - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; NSDate *object = _objects[indexPath.row]; cell.textLabel.text = [[Data getAllNotes] objectForKey:[object description]]; return cell; }
  • 24. View Controllers MasterViewController.m - (void)makeObjects { _objects = [NSMutableArray arrayWithArray:[[Data getAllNotes] allKeys]]; [_objects sortUsingComparator:^NSComparisonResult(id obj1, id obj2) { return [(NSDate *)obj2 compare:(NSDate *)obj1]; }]; }
  • 25. View Controllers MasterViewController.m - (void)insertNewObject:(id)sender { [self makeObjects]; if (!_objects) { _objects = [[NSMutableArray alloc] init]; } //[_objects insertObject:[NSDate date] atIndex:0]; NSString *key = [[NSDate date] description]; [Data setNote:kDefaultText forKey:key]; [Data setCurrentKey:key]; [_objects insertObject:key atIndex:0]; NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0]; [self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; [self performSegueWithIdentifier:kDetailView sender:self]; }
  • 27. View Controllers MasterViewController.m - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { NSDate *object = _objects[indexPath.row]; self.detailViewController.detailItem = object; } } - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"showDetail"]) { NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; NSDate *object = _objects[indexPath.row]; [[segue destinationViewController] setDetailItem:object]; } }
  • 28. View Controllers MasterViewController.m - (void)viewWillAppear:(BOOL)animated { [super viewDidAppear:animated]; [self makeObjects]; [self.tableView reloadData]; }
  • 29. View Controllers MasterViewController.m - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { [Data removeNoteForKey:[_objects objectAtIndex:indexPath.row]]; [Data saveNotes]; [_objects removeObjectAtIndex:indexPath.row]; [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; } else if (editingStyle == UITableViewCellEditingStyleInsert) { // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view. } }
  • 30. OVERVIEW • Lesson 1: Introductions • Lesson 2: iOS specifics • Lesson 3: Data Model • Lesson 4: Logic (Controller) & Interface