SlideShare a Scribd company logo
1 of 21
Download to read offline
Intro to Obj-C 
Design Patterns 
Or how I learned to be less bad 
Haris Amin
GLIMPSE 
A fun way to meet 
new people through 
Instagram
Design Patterns 
• Why do we care? 
• Let’s explore two design patterns in 
Cocoa 
1. Notification Center 
2. Delegates
Notification Center 
• NSNotificationCenter class 
• Easiest to learn (IMHO) but also easiest to 
abuse 
• Very flexible
Notification Center 
• Let’s Grab a NotificationCenter ‘instance’ 
[NSNotificationCenter defaultCenter] 
! 
• Then PUBLISH a specific message (2 ways) 
1. With content 
2. Without Content
Publish Message Without Content 
• We want to notify that something specific 
‘happened’ 
• Method Signature 
- (void)postNotificationName:(NSString 
*)notificationName object:(id)notificationSender
Publish Message Without Content 
- (void)postNotificationName:(NSString 
*)notificationName object:(id)notificationSender 
• E.G. The Video’s current time just updated 
[[NSNotificationCenter defaultCenter] 
postNotificationName:@"TimeUpdated" object:self];
Publish Message With Content 
- (void)postNotificationName:(NSString 
*)notificationName object:(id)notificationSender 
userInfo:(NSDictionary *)userInfo 
• E.G. The Video’s current time just updated 
WITH the actual current time 
[[NSNotificationCenter defaultCenter] 
postNotificationName:@"TimeUpdated" object:self 
userInfo:@{@"currentTime": 20}];
Subscribing to a Message 
- (void)addObserver:(id)notificationObserver 
selector:(SEL)notificationSelector name:(NSString 
*)notificationName object:(id)notificationSender 
• In our VideoPlayer class we will just subscribe 
to the NotificationCenter Message 
[[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(handleTimeUpdate:) 
name:@"TimeUpdated" 
object:nil]; 
- (void)handleTimeUpdate:(NSNotification *)note{ 
// note.userInfo is the CONTENT we passed 
// ... 
}
Notification Center… 
THE GOOD 
• Really flexible 
• Don’t have to define any sort of protocol for your 
messages 
• You can subscribe and publish messages in any 
number of places
Notification Center… 
THE BAD 
• TOO flexible?! 
• Don’t have to define any sort of protocol for your 
messages 
• You can subscribe and publish messages in any 
number of of places
Delegates 
• Very solid pattern 
• Vigorously multitude of Cocoa classes 
(UITableView, UICollectionView, UIAlterView.. 
etc.) 
• You have to define the protocol of the 
messages you send
A Personal Note… 
• I consumed delegates without really 
understanding how they work 
• I used to be scared of trying to implement 
one myself
TIME TO GAIN A 
SUPERPOWER!
Delegates 
• Very solid pattern 
• Vigorously multitude of Cocoa classes 
(UITableView, UICollectionView, UIAlterView.. 
etc.) 
• You have to define the protocol of the 
messages you send
Define a Delegate 
Protocol 
• Very solid pattern 
• Vigorously multitude of Cocoa classes 
(UITableView, UICollectionView, UIAlterView.. 
etc.) 
• You have to define the protocol of the 
messages you send
Define Protocol 
@protocol VideoDelegate; 
! 
@interface Video: NSObject 
! 
@property (nonatomic, weak) id<VideoDelegate> delegate; 
! 
@end 
! 
@protocol VideoDelegate <NSObject> 
@required 
//... 
! 
@optional 
-(void)video:(Video *)video updatedTime:(NSUInteger)currentTime; 
! 
@end // end of delegate protocol
Delegating Methods in 
the Protocol 
• In our Video class, where need be, we will 
delegate respective messages 
@implementation Video 
//.. 
! 
if (self.delegate && [self.delegate 
respondsToSelector:@selector(video:updatedTime)]) { 
[self.delegate video:updatedTime]; 
} 
//.. 
@end
Implement Protocol 
#include "Video.h" // needed to include the @delegate protocol 
info 
! 
@interface VideoPlayer : UIViewController <VideoDelegate> 
@end 
! 
@implementation VideoPlayer 
//.. 
! 
-(void)video:(Video *)video updatedTime:(NSUInteger)currentTime{ 
// HURRAY! We know what the currentTime is :) 
} 
! 
//.. 
@end
A parting note… 
with great SUPER power 
comes great SUPER 
responsibility!
Questions? 
HARIS AMIN 
Cofounder/CO-CTO @itsglimpse 
@harisamin

More Related Content

Similar to Intro to Obj-C Design Patterns or Or how I learned to be less bad

iOS Development: What's New
iOS Development: What's NewiOS Development: What's New
iOS Development: What's NewNascentDigital
 
FI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS BasicsFI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS BasicsPetr Dvorak
 
Getting started with titanium
Getting started with titaniumGetting started with titanium
Getting started with titaniumNaga Harish M
 
Никита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-CНикита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-CDataArt
 
Getting started with Appcelerator Titanium
Getting started with Appcelerator TitaniumGetting started with Appcelerator Titanium
Getting started with Appcelerator TitaniumTechday7
 
MFF UK - Introduction to iOS
MFF UK - Introduction to iOSMFF UK - Introduction to iOS
MFF UK - Introduction to iOSPetr Dvorak
 
iPhone dev intro
iPhone dev introiPhone dev intro
iPhone dev introVonbo
 
Beginning to iPhone development
Beginning to iPhone developmentBeginning to iPhone development
Beginning to iPhone developmentVonbo
 
Bootstrapping iPhone Development
Bootstrapping iPhone DevelopmentBootstrapping iPhone Development
Bootstrapping iPhone DevelopmentThoughtWorks
 
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろうUnity Technologies Japan K.K.
 
CoconutKit
CoconutKitCoconutKit
CoconutKitdefagos
 
Objective-C Is Not Java
Objective-C Is Not JavaObjective-C Is Not Java
Objective-C Is Not JavaChris Adamson
 
Reactive summit 2020 microsoft orleans the easy way
Reactive summit 2020   microsoft orleans the easy wayReactive summit 2020   microsoft orleans the easy way
Reactive summit 2020 microsoft orleans the easy wayJohn Azariah
 
Wahckon[2] - iOS Runtime Hacking Crash Course
Wahckon[2] - iOS Runtime Hacking Crash CourseWahckon[2] - iOS Runtime Hacking Crash Course
Wahckon[2] - iOS Runtime Hacking Crash Courseeightbit
 
Objective-C talk
Objective-C talkObjective-C talk
Objective-C talkbradringel
 
Cappuccino - A Javascript Application Framework
Cappuccino - A Javascript Application FrameworkCappuccino - A Javascript Application Framework
Cappuccino - A Javascript Application FrameworkAndreas Korth
 
Design Patterns in iOS
Design Patterns in iOSDesign Patterns in iOS
Design Patterns in iOSYi-Shou Chen
 

Similar to Intro to Obj-C Design Patterns or Or how I learned to be less bad (20)

iOS Development: What's New
iOS Development: What's NewiOS Development: What's New
iOS Development: What's New
 
FI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS BasicsFI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS Basics
 
Getting started with titanium
Getting started with titaniumGetting started with titanium
Getting started with titanium
 
Ios development
Ios developmentIos development
Ios development
 
Никита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-CНикита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-C
 
Wordpress Shortcode
Wordpress ShortcodeWordpress Shortcode
Wordpress Shortcode
 
Getting started with Appcelerator Titanium
Getting started with Appcelerator TitaniumGetting started with Appcelerator Titanium
Getting started with Appcelerator Titanium
 
MFF UK - Introduction to iOS
MFF UK - Introduction to iOSMFF UK - Introduction to iOS
MFF UK - Introduction to iOS
 
iPhone dev intro
iPhone dev introiPhone dev intro
iPhone dev intro
 
Beginning to iPhone development
Beginning to iPhone developmentBeginning to iPhone development
Beginning to iPhone development
 
Bootstrapping iPhone Development
Bootstrapping iPhone DevelopmentBootstrapping iPhone Development
Bootstrapping iPhone Development
 
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
 
CoconutKit
CoconutKitCoconutKit
CoconutKit
 
Objective-C Is Not Java
Objective-C Is Not JavaObjective-C Is Not Java
Objective-C Is Not Java
 
Reactive summit 2020 microsoft orleans the easy way
Reactive summit 2020   microsoft orleans the easy wayReactive summit 2020   microsoft orleans the easy way
Reactive summit 2020 microsoft orleans the easy way
 
Wahckon[2] - iOS Runtime Hacking Crash Course
Wahckon[2] - iOS Runtime Hacking Crash CourseWahckon[2] - iOS Runtime Hacking Crash Course
Wahckon[2] - iOS Runtime Hacking Crash Course
 
Objective-C talk
Objective-C talkObjective-C talk
Objective-C talk
 
Cappuccino - A Javascript Application Framework
Cappuccino - A Javascript Application FrameworkCappuccino - A Javascript Application Framework
Cappuccino - A Javascript Application Framework
 
React nativebeginner1
React nativebeginner1React nativebeginner1
React nativebeginner1
 
Design Patterns in iOS
Design Patterns in iOSDesign Patterns in iOS
Design Patterns in iOS
 

Recently uploaded

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 

Recently uploaded (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

Intro to Obj-C Design Patterns or Or how I learned to be less bad

  • 1. Intro to Obj-C Design Patterns Or how I learned to be less bad Haris Amin
  • 2. GLIMPSE A fun way to meet new people through Instagram
  • 3. Design Patterns • Why do we care? • Let’s explore two design patterns in Cocoa 1. Notification Center 2. Delegates
  • 4. Notification Center • NSNotificationCenter class • Easiest to learn (IMHO) but also easiest to abuse • Very flexible
  • 5. Notification Center • Let’s Grab a NotificationCenter ‘instance’ [NSNotificationCenter defaultCenter] ! • Then PUBLISH a specific message (2 ways) 1. With content 2. Without Content
  • 6. Publish Message Without Content • We want to notify that something specific ‘happened’ • Method Signature - (void)postNotificationName:(NSString *)notificationName object:(id)notificationSender
  • 7. Publish Message Without Content - (void)postNotificationName:(NSString *)notificationName object:(id)notificationSender • E.G. The Video’s current time just updated [[NSNotificationCenter defaultCenter] postNotificationName:@"TimeUpdated" object:self];
  • 8. Publish Message With Content - (void)postNotificationName:(NSString *)notificationName object:(id)notificationSender userInfo:(NSDictionary *)userInfo • E.G. The Video’s current time just updated WITH the actual current time [[NSNotificationCenter defaultCenter] postNotificationName:@"TimeUpdated" object:self userInfo:@{@"currentTime": 20}];
  • 9. Subscribing to a Message - (void)addObserver:(id)notificationObserver selector:(SEL)notificationSelector name:(NSString *)notificationName object:(id)notificationSender • In our VideoPlayer class we will just subscribe to the NotificationCenter Message [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleTimeUpdate:) name:@"TimeUpdated" object:nil]; - (void)handleTimeUpdate:(NSNotification *)note{ // note.userInfo is the CONTENT we passed // ... }
  • 10. Notification Center… THE GOOD • Really flexible • Don’t have to define any sort of protocol for your messages • You can subscribe and publish messages in any number of places
  • 11. Notification Center… THE BAD • TOO flexible?! • Don’t have to define any sort of protocol for your messages • You can subscribe and publish messages in any number of of places
  • 12. Delegates • Very solid pattern • Vigorously multitude of Cocoa classes (UITableView, UICollectionView, UIAlterView.. etc.) • You have to define the protocol of the messages you send
  • 13. A Personal Note… • I consumed delegates without really understanding how they work • I used to be scared of trying to implement one myself
  • 14. TIME TO GAIN A SUPERPOWER!
  • 15. Delegates • Very solid pattern • Vigorously multitude of Cocoa classes (UITableView, UICollectionView, UIAlterView.. etc.) • You have to define the protocol of the messages you send
  • 16. Define a Delegate Protocol • Very solid pattern • Vigorously multitude of Cocoa classes (UITableView, UICollectionView, UIAlterView.. etc.) • You have to define the protocol of the messages you send
  • 17. Define Protocol @protocol VideoDelegate; ! @interface Video: NSObject ! @property (nonatomic, weak) id<VideoDelegate> delegate; ! @end ! @protocol VideoDelegate <NSObject> @required //... ! @optional -(void)video:(Video *)video updatedTime:(NSUInteger)currentTime; ! @end // end of delegate protocol
  • 18. Delegating Methods in the Protocol • In our Video class, where need be, we will delegate respective messages @implementation Video //.. ! if (self.delegate && [self.delegate respondsToSelector:@selector(video:updatedTime)]) { [self.delegate video:updatedTime]; } //.. @end
  • 19. Implement Protocol #include "Video.h" // needed to include the @delegate protocol info ! @interface VideoPlayer : UIViewController <VideoDelegate> @end ! @implementation VideoPlayer //.. ! -(void)video:(Video *)video updatedTime:(NSUInteger)currentTime{ // HURRAY! We know what the currentTime is :) } ! //.. @end
  • 20. A parting note… with great SUPER power comes great SUPER responsibility!
  • 21. Questions? HARIS AMIN Cofounder/CO-CTO @itsglimpse @harisamin