I was hoping you guys could give me a hand figuring out the best strategy for implementing a simple test app. Essentially, I want a window with 3 NSTextFields each corresponding to a, b, and c of the pythagorean theorem. The user would input values in say a and c and the program would calculate the value of the "b" variable. If this action were initiated by using a Calculate button on the GUI, I think my strategy would be to use if statements to determine which field had a value of nil and then use the appropriate version of the pythagorean theorem with the appropriate values substituted for the variables and calculate the result. Is this a reasonable way to go about doing this?
Now if I wanted to get fancy and remove the calculate button and use a delegate method like textDidEndEditing: so the app would automatically calculate b when both a and c have been entered for example. The problem is that this method will be called after the first value is entered which means I would have to create a test at the beginning of the delegate method call to determine if there is a second field with a value or if the other two are nil. This doesnt seem like a particularly elegant solution (especially if I ever wanted to use formulas with more than 3 variables), and Im wondering if Im on the wrong track here. Should I be doing this by creating an observing controller object and using a NSInvocation/messaging technique or something along those lines? Thanks in advance for pointing me in the right direction.
I should also note that my ultimate intention is to create an app with many different formulas the user can select from, of which, many would have more than 3 variables.
Now if I wanted to get fancy and remove the calculate button and use a delegate method like textDidEndEditing: so the app would automatically calculate b when both a and c have been entered for example. The problem is that this method will be called after the first value is entered which means I would have to create a test at the beginning of the delegate method call to determine if there is a second field with a value or if the other two are nil. This doesnt seem like a particularly elegant solution (especially if I ever wanted to use formulas with more than 3 variables), and Im wondering if Im on the wrong track here. Should I be doing this by creating an observing controller object and using a NSInvocation/messaging technique or something along those lines? Thanks in advance for pointing me in the right direction.
I should also note that my ultimate intention is to create an app with many different formulas the user can select from, of which, many would have more than 3 variables.