Calculator application, pupulating textfield from buttons, iphone

I am creating a simple calculator application. I have 10 buttons labelled 0 through 9, and 5 buttons for the operations. I have an uitextfied which should be populated from the buttons. ie when the user click button 1, 1 should be entered in the field and so on. Also the value entered should be there even if the user taps another one. how to do that..pls help..


You need to declare the textfield (and the buttons) as Outlets in Interface Builder. Then you need to connect the touch up inside event of each button to a method. You can either have 10 methods which is one for each button or just one method and filter on id or tag. In the button actions you can easily update the textfield by appending the the correct number.

I would personally store user input in a NSMutableString, validating input (for numeracy)and adding it to the variable if validation returns true.

Then when a button is pressed it is simply a matter of updating the UITextField with the contents of the NSMutableString.

For the purpose of calculations, the string value can be converted to the appropriate numeric type when a calculation is required.

Need Your Help

How to get information about contents of Qt listbox in another process

c++ qt user-interface accessibility cross-process

I got an application written using Qt and I would like to read data in Qt listbox.

How can I have associations properly set in Factory Girl?

ruby-on-rails-3 factory-girl

I am new to FactoryGirl. I come from the fixtures world.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.