Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 31st, 2012  |  syntax: None  |  size: 7.43 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. objective-c Tabbed App, Thread 1 signal: SIGABRT
  2. 2012-04-26 09:43:01.171 Triangle Solver[9516:f803] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<TriSecondViewController 0x68827d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key solve.'
  3. *** First throw call stack: (0x13ce022 0x155fcd6 0x13cdee1 0x9c6022 0x937f6b 0x937edb 0x952d50 0x23a71a 0x13cfdea 0x13397f1 0x23926e 0xdf1fc 0xdf779 0xdf99b 0xfb0a9 0xfaedd 0xf94aa 0xf934f 0xfae14 0x13cfe99 0x1b14e 0x1b0e6 0x2434bd 0x13cfe99 0x1b14e 0x1b0e6 0xc1ade 0xc1fa7 0xc1b13 0x245c48 0x13cfe99 0x1b14e 0x1b0e6 0xc1ade 0xc1fa7 0xc1266 0x403c0 0x405e6 0x26dc4 0x1a634 0x12b8ef5     0x13a2195 0x1306ff2 0x13058da 0x1304d84 0x1304c9b 0x12b77d8 0x12b788a 0x18626 0x2a0d 0x2975) terminate called throwing an exception(lldb)
  4.        
  5. @interface TriFirstViewController : UIViewController
  6. @property (weak, nonatomic) IBOutlet UITextField *triText1;
  7. @property (weak, nonatomic) IBOutlet UITextField *triText2;
  8. - (IBAction)calc:(id)sender;
  9. @property (weak, nonatomic) IBOutlet UILabel *legA;
  10. @property (weak, nonatomic) IBOutlet UILabel *legB;
  11. @property (weak, nonatomic) IBOutlet UILabel *hypotenuse;
  12. @property (weak, nonatomic) IBOutlet UILabel *angleA;
  13. @property (weak, nonatomic) IBOutlet UILabel *angleB;
  14.  
  15. @property (weak, nonatomic) IBOutlet UIButton *button1;
  16.  
  17. @property (copy, nonatomic) NSString *text1;
  18. @property (copy, nonatomic) NSString *text2;
  19.  
  20. @end
  21.        
  22. @interface TriSecondViewController : UIViewController
  23. @property (weak, nonatomic) IBOutlet UITextField *sines1;
  24. @property (weak, nonatomic) IBOutlet UITextField *sines2;
  25. @property (weak, nonatomic) IBOutlet UITextField *sines3;
  26. - (IBAction)solve2:(id)sender;
  27. @property (weak, nonatomic) IBOutlet UILabel *angleA;
  28. @property (weak, nonatomic) IBOutlet UILabel *sideA;
  29. @property (weak, nonatomic) IBOutlet UILabel *angleB;
  30. @property (weak, nonatomic) IBOutlet UILabel *sideB;
  31. @property (weak, nonatomic) IBOutlet UILabel *angleC;
  32. @property (weak, nonatomic) IBOutlet UILabel *sideC;
  33.  
  34. @property (weak, nonatomic) IBOutlet UISegmentedControl *segControl;
  35. - (IBAction)aassas:(id)sender;
  36. @property (weak, nonatomic) IBOutlet UILabel *sine1;
  37. @property (weak, nonatomic) IBOutlet UILabel *sine2;
  38. @property (weak, nonatomic) IBOutlet UILabel *sine3;
  39.  
  40. @end
  41.        
  42. @end
  43.  
  44. @implementation TriFirstViewController
  45. @synthesize legA;
  46. @synthesize legB;
  47. @synthesize hypotenuse;
  48. @synthesize angleA;
  49. @synthesize angleB;
  50. @synthesize button1;
  51. @synthesize triText1;
  52. @synthesize triText2;
  53.  
  54. @synthesize text1;
  55. @synthesize text2;
  56.  
  57. - (void)viewDidLoad
  58. {
  59.     [super viewDidLoad];
  60.     // Do any additional setup after loading the view, typically from a nib.
  61. }
  62.  
  63. - (void)viewDidUnload
  64. {
  65.     [self setTriText1:nil];
  66.     [self setTriText2:nil];
  67.     [self setLegA:nil];
  68.     [self setLegB:nil];
  69.     [self setHypotenuse:nil];
  70.     [self setAngleA:nil];
  71.     [self setAngleB:nil];
  72.     [self setButton1:nil];
  73.     [super viewDidUnload];
  74.     // Release any retained subviews of the main view.
  75. }
  76.  
  77. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  78. {
  79.     return YES;
  80. }
  81.  
  82. - (IBAction)calc:(id)sender
  83. {
  84.     double aa = 0;
  85.     double ab = 0;
  86.     double la = 0;
  87.     double lb = 0;
  88.     double h = 0;
  89.  
  90.     self.text1 = self.triText1.text;
  91.     self.text2 = self.triText2.text;
  92.  
  93.     aa = [self.text1 doubleValue];
  94.     lb = [self.text2 doubleValue];
  95.  
  96.     ab = 90 - aa;
  97.  
  98.     la = (tan((aa * (M_PI/180))) * lb);
  99.     h = (pow(la, 2) + pow(lb, 2));
  100.     h = sqrt(h);
  101.  
  102.     self.legA.text = [NSString stringWithFormat: @"%.2lf", la];
  103.     self.legB.text = [NSString stringWithFormat: @"%.2lf", lb];
  104.     self.angleA.text = [NSString stringWithFormat: @"%.2lf", aa];
  105.     self.angleB.text = [NSString stringWithFormat: @"%.2lf", ab];
  106.     self.hypotenuse.text = [NSString stringWithFormat: @"%.2lf", h];
  107. }
  108.  
  109. @end
  110.        
  111. @interface TriSecondViewController ()
  112.  
  113. @end
  114.  
  115. @implementation TriSecondViewController
  116. @synthesize sine1;
  117. @synthesize sine2;
  118. @synthesize sine3;
  119. @synthesize angleA;
  120. @synthesize sideA;
  121. @synthesize angleB;
  122. @synthesize sideB;
  123. @synthesize angleC;
  124. @synthesize sideC;
  125. @synthesize segControl;
  126. @synthesize sines1;
  127. @synthesize sines2;
  128. @synthesize sines3;
  129.  
  130. BOOL mode = NO;
  131.  
  132. - (void)viewDidLoad
  133. {
  134.      [super viewDidLoad];
  135.      // Do any additional setup after loading the view, typically from a nib.
  136. }
  137.  
  138. - (void)viewDidUnload
  139. {
  140.     [self setSines1:nil];
  141.     [self setSine2:nil];
  142.     [self setSines3:nil];
  143.     [self setAngleA:nil];
  144.     [self setAngleB:nil];
  145.     [self setAngleC:nil];
  146.     [self setSideA:nil];
  147.     [self setSideB:nil];
  148.     [self setSideC:nil];
  149.     [self setSine1:nil];
  150.     [self setSine2:nil];
  151.     [self setSine3:nil];
  152.     [self setSegControl:nil];
  153.     [super viewDidUnload];
  154.     // Release any retained subviews of the main view.
  155. }
  156.  
  157. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  158. {
  159.     if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
  160.         return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
  161.     } else {
  162.         return YES;
  163.     }
  164. }
  165.  
  166. - (IBAction)solve2:(id)sender
  167. {
  168.     if (mode)
  169.     {
  170.         double aa = [self.sines1.text doubleValue];
  171.         double ab = [self.sines2.text doubleValue];
  172.         double ac = 180 - aa - ab;
  173.         double sa = [self.sines3.text doubleValue];
  174.         double sb;
  175.         double sc;
  176.  
  177.         //convert degrees to radians
  178.         aa = (aa * (M_PI/180));
  179.         ab = (ab * (M_PI/180));
  180.         ac = (ac * (M_PI/180));
  181.  
  182.         sb = (sa/sin(aa))*sin(ab);
  183.         sc = (sa/sin(aa))*sin(ac);
  184.  
  185.         self.angleA.text = [NSString stringWithFormat: @"%.2lf", aa];
  186.         self.angleB.text = [NSString stringWithFormat: @"%.2lf", ab];
  187.         self.angleC.text = [NSString stringWithFormat: @"%.2lf", ac];
  188.         self.sideA.text = [NSString stringWithFormat: @"%.2lf", sa];
  189.         self.sideB.text = [NSString stringWithFormat: @"%.2lf", sb];
  190.         self.sideC.text = [NSString stringWithFormat: @"%.2lf", sc];
  191.     }
  192.  
  193.     if (!mode)
  194.     {
  195.         double aa = [self.sines1.text doubleValue];
  196.         double ab;
  197.         double ac;
  198.         double sa = [self.sines2.text doubleValue];
  199.         double sb = [self.sines3.text doubleValue];
  200.         double sc;
  201.  
  202.         aa = (aa * (M_PI/180));
  203.  
  204.         ab = asin(sb*(sin(aa)/sa));
  205.         ac = 180 - aa - ab;
  206.  
  207.         ac = (ac * (M_PI/180));
  208.  
  209.         sc = (sa/sin(aa))*sin(ac);
  210.  
  211.         self.angleA.text = [NSString stringWithFormat: @"%.2lf", aa];
  212.         self.angleB.text = [NSString stringWithFormat: @"%.2lf", ab];
  213.         self.angleC.text = [NSString stringWithFormat: @"%.2lf", ac];
  214.         self.sideA.text = [NSString stringWithFormat: @"%.2lf", sa];
  215.         self.sideB.text = [NSString stringWithFormat: @"%.2lf", sb];
  216.         self.sideC.text = [NSString stringWithFormat: @"%.2lf", sc];
  217.     }
  218. }
  219.  
  220. - (IBAction)aassas:(id)sender
  221. {
  222.     switch (self.segControl.selectedSegmentIndex) {
  223.         case 0:
  224.             self.sine1.text = @"Angle A/n";
  225.             self.sine2.text = @"Angle B/n";
  226.             self.sine3.text = @"Side A/n";
  227.             mode = NO;
  228.             break;
  229.  
  230.         case 1:
  231.             self.sine1.text = @"Angle A/n";
  232.             self.sine2.text = @"Side A/n";
  233.             self.sine3.text = @"Side B/n";
  234.             mode = YES;
  235.             break;
  236.  
  237.         default:
  238.             break;
  239.     }
  240. }
  241. @end
  242.        
  243. [self setTriText1:nil];
  244. [self setTriText2:nil];
  245. [self setLegA:nil];
  246. [self setLegB:nil];
  247. [self setHypotenuse:nil];
  248. [self setAngleA:nil];
  249. [self setAngleB:nil];
  250. [self setButton1:nil];
  251.        
  252. self.triText1 = nil;
  253. self.triText2 = nil;
  254. self.legA = nil;