using the result of a UILabel after a calculation in another calculation in Xcode

I hope what I'm about makes sense. what I am trying to do is use the result of say a - b = c. Now "a" and "b" are both UITextfields and "C" is a UILabel.

I want to be able to use the result of "c" to take "a" place each time the calculation is run.

Example: 100 - 30 = 70, then the next time I want to add another figure in position "b", "a" is now result of "c".

Now I also want to keep the original result of "a" in the textfield I entered first so I have it as a reference point. but would like to have the "c" result to drop each time I enter a figure into "b". now how do I code this?

The first part I have but not the second part.

heres my first part of the code

-(IBAction)calculate:(id)sender {
NSString *spCash = self.spendingCash.text;
NSString *recAmount = self.receiptAmount.text;

float cashFloat;
float receiptFloat =[recAmount floatValue];
float spendingFloat = [spCash floatValue];

cashFloat = spendingFloat - receiptFloat;

NSString *cashAv = [[NSString alloc]initWithFormat:@"$%.2f", cashFloat];

self.cashAvailable.text = cashAv; 

I hope this makes sense.

Thanks for your time and look forward to reading some responses.


Don't depend on storing data in UI elements.

Create properties (probably in your view controller) to represent the numbers that people enter and the results of your calculations. That way you can save whatever information you need and not depend on whether or not it's visible on the screen.

Need Your Help

Parse XML with VBA

xml excel vba excel-vba xml-parsing

I'm trying to parse xml with VBA to obtain test results from an electrical test system. This is an example of what the system is giving me:

How to query Xml file using java

java xml xml-parsing

I am having Xml file which contains about 50 Tables <tables></tables>. All tables are linked to each other.