I have two UITextFields one field is RISK and other is WIN. Now when user start writing in RISK field then it should accordingly calculate the value of WIN and should be filled in WIN field. Formula is this
if (a<0) {
WIN = RISK/(-a/100)
}
else {
WIN = RISK*(a/100)
}
and if value is entered in WIN then it should populate the value in RISK, formula is
if (a<0) {
RISK = WIN*(-a/100)
}
else {
RISK= WIN*(100/a)
}
so please guys guide me how can i populate the fields without pressing any button and how can i calculate the values?
Thanx in advance
Assuming you have a property for each field:
and
IBActionmethods:Hook these up in interface builder to the Editing Changed event:
Your method will look something like:
.. and similarly for
riskDidChange:If you hook up the Editing Changed event of the
winfield to thewinDidChange:IBActionin interface builder (and the same forrisk), the method will be called every time a character is typed into the field.You should read The Target-Action Mechanism section in http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaDesignPatterns/CocoaDesignPatterns.html