It looks like you're new here. If you want to get involved, click one of these buttons!
- (void)viewDidLoad {
self.fromArray = [[NSArray alloc] initWithObjects:
@"Annual", @"Monthly", @"48/Year", @"SemiMonthly", @"BiWeekly", @"Weekly", @"Hourly", nil];
self.fromValues = [[NSArray alloc] initWithObjects:
[NSNumber numberWithFloat:1.0],
[NSNumber numberWithFloat:12.0],
[NSNumber numberWithFloat:48.0],
[NSNumber numberWithFloat:24.0],
[NSNumber numberWithFloat:26.0],
[NSNumber numberWithFloat:52.0],
[NSNumber numberWithFloat:2080.0], nil];
self.toArray = [[NSArray alloc] initWithObjects:
@"Annual", @"Monthly", @"48/Year", @"SemiMonthly", @"BiWeekly", @"Weekly", @"Hourly", nil];
self.toValues = [[NSArray alloc] initWithObjects:
[NSNumber numberWithFloat:1.0],
[NSNumber numberWithFloat:12.0],
[NSNumber numberWithFloat:48.0],
[NSNumber numberWithFloat:24.0],
[NSNumber numberWithFloat:26.0],
[NSNumber numberWithFloat:52.0],
[NSNumber numberWithFloat:2080.0], nil];
Also, how would I properly format a calculation using values from both components and a Text Field? This is just not working.
- (IBAction)Convert:(id)sender {
float valuein = [[fromValues objectAtIndex:row] floatValue];
float valueout = [[toValues objectAtIndex:row] floatValue];
float input = [inputText.text floatValue];
float result = input * valuein / valueout;
NSString *resultString = [[NSString alloc] initWithFormat: @"$ %@", [toArray objectAtIndex:row]];
}
Replies
As far as your calculation, you aren't doing anything with "result".
SlickShopper 2 | BTIConcepts on GitHub | Free NSLog utility | Free Getter Utility | Leave a PayPal donation.
Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | A Model (Object) Is A Beautiful Thing
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeFor the calculation, I tried this, but I get undeclared identifier errors with the use of 'row'. It would seem I need to declare 'row', but the single-componenent tutorial I derived that bit of code from looked something like the following, so I'm not sure what's wrong.
I had also tried this, but I got "No visible @interface for 'NSArray' declares the selector 'text'." errors.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeAs for the rest, sound like you need to sit down with a good iOS development book. You're missing some fundamentals.
SlickShopper 2 | BTIConcepts on GitHub | Free NSLog utility | Free Getter Utility | Leave a PayPal donation.
Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | A Model (Object) Is A Beautiful Thing
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI've been through 3 iPhone/iOS/Xcode books, as well as myriad resources online from books to tutorials to sample code to how-to videos. The one thing I have missed is Objective-C fundamentals, relying instead on Xcode's ease-of-use and graphical user interface. As a result, I've managed to accomplish all of the many goals I have set for my project - until now. The biggest downside is only knowing everything works, and not always why. Thank you for the advice. I'll keep plugging away at this until I figure it out.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeSo: The "component" value was provided as one of the input variables in the method declaration. If the component value is zero (this means it is the first, or left-most, component), then: The "row" value was also provided as an input variable. Go to the array instance variable called "fromArray", select the object in the array that is at the index equivalent to row, and return it. The method exits at this point if this condition was executed. This code is only run if the component is not zero. This time, go to the array instance variable called "toArray", select the object in the array that is at the index equivalent to the row, and return it.
Now then, what do you need to change in order for each component to use the same array?
SlickShopper 2 | BTIConcepts on GitHub | Free NSLog utility | Free Getter Utility | Leave a PayPal donation.
Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | A Model (Object) Is A Beautiful Thing
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI'm afraid any "brushing up" would imply I had been over it before. As I said, my experience is limited to making Xcode do what I need and finding examples of more complex functions that I can modify to suit my needs - not the fundamental basics of how Objective-C works. Probably akin to knowing how to drive a car and change the oil without knowing exactly how to make the engine work. But thanks for the followup.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome