Delegation Object Messaging
What is Delegation?Delegation is a design pattern in object-orientedprogramming where an object, instead ofperforming one ...
Examples: AppDelegate• UIApplicationDelegate - (BOOL)application:(UIApplication     *)application     didFinishLaunchingWi...
Examples: UITableView• UITableViewDelegate - UITableViewCell *)tableView:     (UITableView *)tableView     cellForRowAtInd...
What Problem Does Delegation Solve?  Object A   Object B
Write to File          Object A                     Object B        (Equipment)                 (User Interface)          ...
Define Pointers            Object A                     Object B          (Equipment)                 (User Interface)Objec...
App                            Delegate                                            Define Property            Object A     ...
App                      Delegate                                  Define Delegate          Object A                  Objec...
Demo• Build a Program using Delegation
Upcoming SlideShare
Loading in...5
×

Delegation Slides

835

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
835
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
27
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript of "Delegation Slides"

    1. 1. Delegation Object Messaging
    2. 2. 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)
    3. 3. Examples: AppDelegate• UIApplicationDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions - (void)applicationWillTerminate: (UIApplication *)application
    4. 4. Examples: UITableView• UITableViewDelegate - UITableViewCell *)tableView: (UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath - ...tableView:didDeselectRowAtIndexPath:
    5. 5. What Problem Does Delegation Solve? Object A Object B
    6. 6. Write to File Object A Object B (Equipment) (User Interface) somefile.txt
    7. 7. Define Pointers Object A Object B (Equipment) (User Interface)ObjectB *myObject;myObject = [self getSomeData:data];
    8. 8. App Delegate Define Property Object A Object B (Equipment) (User Interface)AppDelegate *d = [[UIApplication sharedApplication] delegate];d.someString = ...
    9. 9. 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
    10. 10. Demo• Build a Program using Delegation
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×