Advertisement
RRK

Inheritance

RRK
Nov 6th, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Here first I am showing two functions, Whether these functions can be reduced to one something shown at bottom because both Boss and Employee are NSManagedObject.
  2.  
  3. -(void)configureCell:(Boss *)bossObject
  4. {
  5.     self.BackgroundImage.image = [UIImage imageWithData:bossObject.image];
  6.     self.boss = bossObject;
  7.    
  8.    
  9.     UIImage *backgroundImage;
  10.    
  11.     if (self.boss.completedStatus)
  12.     {
  13.         backgroundImage = [self completedBackgroundImage];
  14.     }
  15.     else
  16.     {
  17.         backgroundImage = [self defaultBackgroundImage];
  18.     }    
  19.     self.cellBackgroundImage.image = backgroundImage;    
  20. }
  21.  
  22. -(void)configureCell:(Employee *)employeeObject
  23. {
  24.     self.BackgroundImage.image = [UIImage imageWithData:employeeObject.image];
  25.     self.employee = employeeObject;
  26.    
  27.    
  28.     UIImage *backgroundImage;
  29.    
  30.     if (self.employee.completedStatus)
  31.     {
  32.         backgroundImage = [self completedBackgroundImage];
  33.     }
  34.     else
  35.     {
  36.         backgroundImage = [self defaultBackgroundImage];
  37.     }    
  38.     self.cellBackgroundImage.image = backgroundImage;    
  39. }
  40.  
  41. Instead of writing these two separate functions, To reduce the duplication of code, can only one function be written some thing like this
  42.  
  43.  
  44.  
  45. -(void)configureCell:(NSManagedObject *)Object
  46. {
  47.     But here I dont know how to access the completion status here    
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement