allandriggers
Apple Fan
Profile
Posts: 188
Reg: Dec 13, 2012
Knoxville, TN
11,680
07/19/13 08:01 PM (12 years ago)

Programming Help

I'm trying to add a payment calculator to my app to help my chances of getting approved. I'm getting syntax errors in my .m file and i'm not really sure what I'm doing wrong. I was hoping someone a little more experienced than me could look at what I'm doing and tell me where I'm screwing up. Any help would be great. // // ViewController.h // PaymentCalculator #import <UIKit/UIKit.h> @interface ViewController : UIViewController{ IBOutlet UITextField *amountFin; IBOutlet UITextField *loanTerm; IBOutlet UITextField *rate; IBOutlet UILabel *payment; } -(IBAction)submit; -(IBAction)clear; @end // // ViewController.m // PaymentCalculator #import "ViewController.h" @implementation ViewController -(IBAction) submit{ float p = ([amountFin.text floatValue]); int x = ([loanTerm.text intValue]); float r = ([rate.text floatValue]); float a; a =(p)(r(1+r)^x)/(1+r)^x)-1)); <<Error payment.text [[NSString alloc]initWithFormat: @"%a.f", a]; <<Error } -(IBAction) clear{ amountFin.text = @""; loanTerm.text = @""; rate.text = @""; payment.text = @"; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
 
nadthevlad
Code is Art
Profile
Posts: 1025
Reg: Jun 07, 2012
Denver
21,850
like
07/19/13 11:39 PM (12 years ago)
Your variables need to be synthesized. And properties added. Look up @synthesize and @property in relation to ios programming.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
07/20/13 12:12 AM (12 years ago)
Nad is correct; Those variables won't be recognized until you synthesize them... Gloss over the way they did this one: http://easyiphonedevelopment.blogspot.com/2010/07/easy-loan-calculator-part-1.html http://easyiphonedevelopment.blogspot.com/2010/07/implementing-easy-loan-calculator.html Cheers! -- Smug
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
07/20/13 06:30 AM (12 years ago)
Actually, he doesn't have any properties declared, so they don't need to be synthesized. Wouldn't cause the syntax error anyway. Instead, change your floats to CGFloats, and your offending lines to: a =(p)*(r*(1+r)^x)/(1+r)^x)-1)); payment.text = [[NSString alloc]initWithFormat: @"%f", a]; Hopefully that works. I'm doing this on my phone, so I may be missing something.
 
allandriggers
Apple Fan
Profile
Posts: 188
Reg: Dec 13, 2012
Knoxville, TN
11,680
like
07/20/13 06:49 AM (12 years ago)
Thank you very much guys. That is going to help me a lot.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.