• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Delegation Slides
 

Delegation Slides

on

  • 952 views

 

Statistics

Views

Total Views
952
Views on SlideShare
946
Embed Views
6

Actions

Likes
0
Downloads
22
Comments
0

1 Embed 6

http://mobiledevnj.com 6

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Delegation Slides Delegation Slides Presentation Transcript

  • Delegation Object Messaging
  • What is Delegation?Delegation is a design pattern in object-orientedprogramming where an object, instead ofperforming one of its stated tasks, delegates thattask to an associated helper object. It passes thebuck, so to speak (technically, an Inversion ofResponsibility).The helper object is called the delegate. (source:Wikepedia)
  • Examples: AppDelegate• UIApplicationDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions - (void)applicationWillTerminate: (UIApplication *)application
  • Examples: UITableView• UITableViewDelegate - UITableViewCell *)tableView: (UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath - ...tableView:didDeselectRowAtIndexPath:
  • What Problem Does Delegation Solve? Object A Object B
  • Write to File Object A Object B (Equipment) (User Interface) somefile.txt
  • Define Pointers Object A Object B (Equipment) (User Interface)ObjectB *myObject;myObject = [self getSomeData:data];
  • App Delegate Define Property Object A Object B (Equipment) (User Interface)AppDelegate *d = [[UIApplication sharedApplication] delegate];d.someString = ...
  • App Delegate Define Delegate Object A Object B (Equipment) (User Interface)• Create Delegate Object • Helper App• Defines Protocols • Delegate of Object A - List of methods • Implements Protocol
  • Demo• Build a Program using Delegation