Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-08-2009, 01:38 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 9
Question calculations and variables

Hi,
I've just begun learning objective C and iPhone devleopement. I want to create something in iphone sdk, that has a user input in some numbers in a field and calculates the solution.
(ex: input1 * input2 = solution, or input1 + input2 * input 3 = solution).

I am having trouble finding the right code to make this work for me.
If anyone can be kind enough to help me out with some sample code, I would very much appreciate it!!

thanks, danny

Last edited by danny8; 09-08-2009 at 03:50 PM.
danny8 is offline   Reply With Quote
Old 09-08-2009, 05:08 PM   #2 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,558
Send a message via ICQ to smithdale87 Send a message via AIM to smithdale87 Send a message via Skype™ to smithdale87
Default

Have you tried anything yet?
smithdale87 is offline   Reply With Quote
Old 09-08-2009, 05:35 PM   #3 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

Do you know how to do this in any other language? The only cocoa-specific stuff would be reading the equation from a text field

Code:
NSString * equationString = mytextField.text;
The real work is done by parsing the equation into some kind of a tree structure and evaluating that structure.

Edit: the original question mentioned parsing an equation (or I misread it.)
__________________

Free Games!

Last edited by smasher; 09-09-2009 at 02:58 PM.
smasher is offline   Reply With Quote
Old 09-09-2009, 02:34 AM   #4 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: New Zealand
Posts: 189
Default

create 3 textfields in IB, synthesize three outlets in Xcode, Link the outlets to the textfields, read each value: int valInput1 = [input1.text intValue]; etc
LemonMeringue is offline   Reply With Quote
Reply

Bookmarks

Tags
calculator, iphone sdk, numbers, variables

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 346
20 members and 326 guests
ADY, Alsahir, Dani77, e2applets, JasonR, keeshux, linkmx, mer10, Monstertaco, piesia, prchn4christ, Promo Dispenser, Robiwan, sebasx, sly24, Touchmint, twerner, zulfishah
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,760
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:29 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0