Guest User

Untitled

a guest
Jun 10th, 2013
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*----- header snippet ------*/
  2.  
  3. @property (strong, nonatomic) IBOutlet UIView *labels1;
  4. @property (strong, nonatomic) IBOutlet UIView *labels2;
  5. @property (strong, nonatomic) IBOutlet UIView *labels3;
  6. @property (strong, nonatomic) IBOutlet UIView *labels4;
  7.  
  8. @property (strong, nonatomic) IBOutletCollection(UIView) NSArray *labelViews;
  9.  
  10. /*----- end header -----*/
  11.  
  12.         UILabel *l1;
  13.         UILabel *l2;
  14.        
  15. //this code should be the same as the code thats uncommented below it but gets an unrecognised selector error
  16.         /*for(UIView *view in self.labelViews){
  17.            
  18.             UILabel *l1 = (UILabel*)[view viewWithTag:1]; //this should be a label but seems to come out as a UIView
  19.             UILabel *l2 = (UILabel*)[view viewWithTag:2];
  20.  
  21.             if([[Hex sharedHex] isPressureMode]){
  22.                 l1.text = [NSString stringWithFormat:@"%d", (int)[[Hex sharedHex] averageforChannel:view.tag]];
  23.             }
  24.             else {
  25.                 l1.text = [NSString stringWithFormat:@"%d", (int)([[[Hex sharedHex] atmosphericPressure] intValue] - [[Hex sharedHex] averageforChannel:view.tag])];
  26.             }
  27.            
  28.             if(reference == view.tag)
  29.                 l2.text = @"Reference";
  30.             else
  31.                 l2.text = [NSString stringWithFormat:@"Δ %d", ((int)[[Hex sharedHex]  averageforChannel:view.tag] - (int)referenceAmount)];
  32.         }*/
  33.        
  34. //this below works fine
  35.         switch (numberOfCylinders) {
  36.             case 4:
  37.                 l1 = (UILabel*)[_labels4 viewWithTag:1];
  38.                 l2 = (UILabel*)[_labels4 viewWithTag:2];
  39.                
  40.                 if([[Hex sharedHex] isPressureMode]){
  41.                     l1.text = [NSString stringWithFormat:@"%d", (int)[[Hex sharedHex] averageforChannel:3]];
  42.                 }
  43.                 else {
  44.                     l1.text = [NSString stringWithFormat:@"%d", (int)([[[Hex sharedHex] atmosphericPressure] intValue] - [[Hex sharedHex] averageforChannel:3])];
  45.                 }
  46.                
  47.                 if(reference == 3)
  48.                     l2.text = @"Reference";
  49.                 else
  50.                     l2.text = [NSString stringWithFormat:@"\u0394 %d", ((int)[[Hex sharedHex]  averageforChannel:3] - (int)referenceAmount)];
  51.             case 3:
  52.                 l1 = (UILabel*)[_labels3 viewWithTag:1];
  53.                 l2 = (UILabel*)[_labels3 viewWithTag:2];
  54.                
  55.                 if([[Hex sharedHex] isPressureMode]){
  56.                     l1.text = [NSString stringWithFormat:@"%d", (int)[[Hex sharedHex] averageforChannel:2]];
  57.                 }
  58.                 else {
  59.                     l1.text = [NSString stringWithFormat:@"%d", (int)([[[Hex sharedHex] atmosphericPressure] intValue] - [[Hex sharedHex] averageforChannel:2])];
  60.                 }
  61.                
  62.                 if(reference == 2)
  63.                     l2.text = @"Reference";
  64.                 else
  65.                     l2.text = [NSString stringWithFormat:@"\u0394 %d", ((int)[[Hex sharedHex]  averageforChannel:2] - (int)referenceAmount)];
  66.             case 2:
  67.                 l1 = (UILabel*)[_labels2 viewWithTag:1];
  68.                 l2 = (UILabel*)[_labels2 viewWithTag:2];
  69.                
  70.                 if([[Hex sharedHex] isPressureMode]){
  71.                     l1.text = [NSString stringWithFormat:@"%d", (int)[[Hex sharedHex] averageforChannel:1]];
  72.                 }
  73.                 else {
  74.                     l1.text = [NSString stringWithFormat:@"%d", (int)([[[Hex sharedHex] atmosphericPressure] intValue] - [[Hex sharedHex] averageforChannel:1])];
  75.                 }
  76.                
  77.                 if(reference == 1)
  78.                     l2.text = @"Reference";
  79.                 else
  80.                     l2.text = [NSString stringWithFormat:@"\u0394 %d", ((int)[[Hex sharedHex]  averageforChannel:1] - (int)referenceAmount)];
  81.             case 1:
  82.                 l1 = (UILabel*)[_labels1 viewWithTag:1];
  83.                 l2 = (UILabel*)[_labels1 viewWithTag:2];
  84.                
  85.                 if([[Hex sharedHex] isPressureMode]){
  86.                     l1.text = [NSString stringWithFormat:@"%d", (int)[[Hex sharedHex] averageforChannel:0]];
  87.                 }
  88.                 else {
  89.                     l1.text = [NSString stringWithFormat:@"%d", (int)([[[Hex sharedHex] atmosphericPressure] intValue] - [[Hex sharedHex] averageforChannel:0])];
  90.                 }
  91.                
  92.                 if(reference == 0)
  93.                     l2.text = @"Reference";
  94.                 else
  95.                     l2.text = [NSString stringWithFormat:@"\u0394 %d", ((int)[[Hex sharedHex]  averageforChannel:0] - (int)referenceAmount)];
  96.             default:
  97.                 break;
  98.         }
Advertisement
Add Comment
Please, Sign In to add comment