SlideShare a Scribd company logo
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

More Related Content

What's hot (20)

PDF
Programming Google apps with the G Suite APIs
DevFest DC
 
PDF
JavaScript para Graficos y Visualizacion de Datos - BogotaJS
philogb
 
PDF
Functional Reactive Programming - RxSwift
Rodrigo Leite
 
PDF
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
GOKUL SREE
 
PPTX
Object Oriented Programing in JavaScript
Akshay Mathur
 
PDF
iOS State Preservation and Restoration
Robert Brown
 
PPTX
Goa tutorial
Bruce McPherson
 
PPTX
Wix Automation - DIY - Testing BI Events
Efrat Attas
 
PDF
Formacion en movilidad: Conceptos de desarrollo en iOS (IV)
Mobivery
 
KEY
iOSDevCamp 2011 Core Data
Chris Mar
 
PPTX
Mobile Developers Talks: Delve Mobile
Konstantin Loginov
 
PPTX
The next step, part 2
Pat Cavit
 
PPTX
Asynchronous programming
Filip Ekberg
 
PPTX
No More Deadlocks; Asynchronous Programming in .NET
Filip Ekberg
 
PDF
[4developers] The saga pattern v3- Robert Pankowiecki
PROIDEA
 
PPT
Intorduction of Playframework
maltiyadav
 
PPTX
Cnam azure 2014 mobile services
Aymeric Weinbach
 
PDF
2 years after the first event - The Saga Pattern
Robert Pankowecki
 
PDF
Reactive Programming Patterns with RxSwift
Florent Pillet
 
PPT
jQuery for beginners
Divakar Gu
 
Programming Google apps with the G Suite APIs
DevFest DC
 
JavaScript para Graficos y Visualizacion de Datos - BogotaJS
philogb
 
Functional Reactive Programming - RxSwift
Rodrigo Leite
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
GOKUL SREE
 
Object Oriented Programing in JavaScript
Akshay Mathur
 
iOS State Preservation and Restoration
Robert Brown
 
Goa tutorial
Bruce McPherson
 
Wix Automation - DIY - Testing BI Events
Efrat Attas
 
Formacion en movilidad: Conceptos de desarrollo en iOS (IV)
Mobivery
 
iOSDevCamp 2011 Core Data
Chris Mar
 
Mobile Developers Talks: Delve Mobile
Konstantin Loginov
 
The next step, part 2
Pat Cavit
 
Asynchronous programming
Filip Ekberg
 
No More Deadlocks; Asynchronous Programming in .NET
Filip Ekberg
 
[4developers] The saga pattern v3- Robert Pankowiecki
PROIDEA
 
Intorduction of Playframework
maltiyadav
 
Cnam azure 2014 mobile services
Aymeric Weinbach
 
2 years after the first event - The Saga Pattern
Robert Pankowecki
 
Reactive Programming Patterns with RxSwift
Florent Pillet
 
jQuery for beginners
Divakar Gu
 

Viewers also liked (6)

PDF
とりあえず使うScalaz
Shuya Tsukamoto
 
PDF
Functional Programming, Is It Worth It?
Andrew Rollins
 
PDF
An introduction to functional programming with Swift
Fatih Nayebi, Ph.D.
 
PPTX
iOS Beginners Lesson 3
Calvin Cheng
 
PDF
Functional Programming for OO Programmers (part 1)
Calvin Cheng
 
PDF
Functional Programming for OO Programmers (part 2)
Calvin Cheng
 
とりあえず使うScalaz
Shuya Tsukamoto
 
Functional Programming, Is It Worth It?
Andrew Rollins
 
An introduction to functional programming with Swift
Fatih Nayebi, Ph.D.
 
iOS Beginners Lesson 3
Calvin Cheng
 
Functional Programming for OO Programmers (part 1)
Calvin Cheng
 
Functional Programming for OO Programmers (part 2)
Calvin Cheng
 
Ad

Similar to iOS Beginners Lesson 4 (20)

PDF
201104 iphone navigation-based apps
Javier Gonzalez-Sanchez
 
PDF
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 05)
Jonathan Engelsma
 
PDF
Session 14 - Working with table view and search bar
Vu Tran Lam
 
PPTX
Android and IOS UI Development (Android 5.0 and iOS 9.0)
Michael Shrove
 
PDF
Modular View Controller Hierarchies
René Cacheaux
 
PDF
Intro to UIKit • Made by Many
kenatmxm
 
PPTX
iOS Development (Part 2)
Asim Rais Siddiqui
 
PDF
Swift
Larry Ball
 
PDF
IOS APPs Revision
Muhammad Amin
 
PDF
Using a model view-view model architecture for iOS apps
allanh0526
 
PDF
iOS Contact List Application Tutorial
Ishara Amarasekera
 
PDF
iOS: Table Views
Jussi Pohjolainen
 
PDF
10 tips for a reusable architecture
Jorge Ortiz
 
PDF
아이폰강의(4) pdf
sunwooindia
 
PPT
iOS Programming 101
rwenderlich
 
PDF
iOS viper presentation
Rajat Datta
 
PDF
Creating Container View Controllers
Bob McCune
 
PPTX
Table views
Hameed Rasheed
 
PPTX
iOS Beginners Lesson 2
Calvin Cheng
 
PDF
iOS 101 - Xcode, Objective-C, iOS APIs
Subhransu Behera
 
201104 iphone navigation-based apps
Javier Gonzalez-Sanchez
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 05)
Jonathan Engelsma
 
Session 14 - Working with table view and search bar
Vu Tran Lam
 
Android and IOS UI Development (Android 5.0 and iOS 9.0)
Michael Shrove
 
Modular View Controller Hierarchies
René Cacheaux
 
Intro to UIKit • Made by Many
kenatmxm
 
iOS Development (Part 2)
Asim Rais Siddiqui
 
Swift
Larry Ball
 
IOS APPs Revision
Muhammad Amin
 
Using a model view-view model architecture for iOS apps
allanh0526
 
iOS Contact List Application Tutorial
Ishara Amarasekera
 
iOS: Table Views
Jussi Pohjolainen
 
10 tips for a reusable architecture
Jorge Ortiz
 
아이폰강의(4) pdf
sunwooindia
 
iOS Programming 101
rwenderlich
 
iOS viper presentation
Rajat Datta
 
Creating Container View Controllers
Bob McCune
 
Table views
Hameed Rasheed
 
iOS Beginners Lesson 2
Calvin Cheng
 
iOS 101 - Xcode, Objective-C, iOS APIs
Subhransu Behera
 
Ad

More from Calvin Cheng (11)

PDF
FOSSASIA 2018 Self-Sovereign Identity with Hyperledger Indy/Sovrin
Calvin Cheng
 
PDF
Hashgraph as Code
Calvin Cheng
 
PPTX
iOS Beginners Lesson 1
Calvin Cheng
 
PPTX
So, you want to build a Bluetooth Low Energy device?
Calvin Cheng
 
PPT
Fabric
Calvin Cheng
 
KEY
Learning iOS and hunting NSZombies in 3 weeks
Calvin Cheng
 
KEY
Ladypy 01
Calvin Cheng
 
KEY
zhng your vim
Calvin Cheng
 
KEY
Django101 geodjango
Calvin Cheng
 
KEY
Saving Gaia with GeoDjango
Calvin Cheng
 
PDF
Agile Apps with App Engine
Calvin Cheng
 
FOSSASIA 2018 Self-Sovereign Identity with Hyperledger Indy/Sovrin
Calvin Cheng
 
Hashgraph as Code
Calvin Cheng
 
iOS Beginners Lesson 1
Calvin Cheng
 
So, you want to build a Bluetooth Low Energy device?
Calvin Cheng
 
Fabric
Calvin Cheng
 
Learning iOS and hunting NSZombies in 3 weeks
Calvin Cheng
 
Ladypy 01
Calvin Cheng
 
zhng your vim
Calvin Cheng
 
Django101 geodjango
Calvin Cheng
 
Saving Gaia with GeoDjango
Calvin Cheng
 
Agile Apps with App Engine
Calvin Cheng
 

Recently uploaded (20)

PPTX
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
PPTX
Explanation about Structures in C language.pptx
Veeral Rathod
 
PDF
Troubleshooting Virtual Threads in Java!
Tier1 app
 
PPTX
Farrell__10e_ch04_PowerPoint.pptx Programming Logic and Design slides
bashnahara11
 
PDF
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
PDF
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
PDF
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
PDF
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
PDF
How Agentic AI Networks are Revolutionizing Collaborative AI Ecosystems in 2025
ronakdubey419
 
PDF
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
PDF
Step-by-Step Guide to Install SAP HANA Studio | Complete Installation Tutoria...
SAP Vista, an A L T Z E N Company
 
PDF
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
PDF
Protecting the Digital World Cyber Securit
dnthakkar16
 
PDF
System Center 2025 vs. 2022; What’s new, what’s next_PDF.pdf
Q-Advise
 
PDF
Salesforce Pricing Update 2025: Impact, Strategy & Smart Cost Optimization wi...
GetOnCRM Solutions
 
PDF
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
PDF
Virtual Threads in Java: A New Dimension of Scalability and Performance
Tier1 app
 
PDF
10 posting ideas for community engagement with AI prompts
Pankaj Taneja
 
PPTX
Presentation about Database and Database Administrator
abhishekchauhan86963
 
PPTX
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
Explanation about Structures in C language.pptx
Veeral Rathod
 
Troubleshooting Virtual Threads in Java!
Tier1 app
 
Farrell__10e_ch04_PowerPoint.pptx Programming Logic and Design slides
bashnahara11
 
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
How Agentic AI Networks are Revolutionizing Collaborative AI Ecosystems in 2025
ronakdubey419
 
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
Step-by-Step Guide to Install SAP HANA Studio | Complete Installation Tutoria...
SAP Vista, an A L T Z E N Company
 
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
Protecting the Digital World Cyber Securit
dnthakkar16
 
System Center 2025 vs. 2022; What’s new, what’s next_PDF.pdf
Q-Advise
 
Salesforce Pricing Update 2025: Impact, Strategy & Smart Cost Optimization wi...
GetOnCRM Solutions
 
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
Virtual Threads in Java: A New Dimension of Scalability and Performance
Tier1 app
 
10 posting ideas for community engagement with AI prompts
Pankaj Taneja
 
Presentation about Database and Database Administrator
abhishekchauhan86963
 
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 

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