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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.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-11-2010, 07:48 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 5
darkmist is on a distinguished road
Question Replace Operators with Variables?

int x = 5;
int y = 3;
char z = '+';
int theFinalAnswers = x z y; // 5 + 3

Ok, needless to say this code doesn't do what it's meant to. I am doing a card game solver that has thousands of possible equations and I'm going to do them all in this program to see if any have the answer that equals the "goal". I considered using functions for the operators but I'm rather new the iPhone SDK. Can you call functions from the ___viewcontroller.m file? Should you just add it before my IBActions function as a int functions? Inside the @implementation thing/block?
darkmist is offline   Reply With Quote
Old 09-11-2010, 08:01 PM   #2 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 5
darkmist is on a distinguished road
Unhappy Anything?

Anything? Any ideas? Even if you're clueless please say so because I feel alone.
darkmist is offline   Reply With Quote
Old 09-11-2010, 08:28 PM   #3 (permalink)
Registered Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
smasher will become famous soon enough
Default

No 'ffense, but it sounds like you're in the "hello world" phase and not ready for a project like this. I'd get a book, do some sample projects first. To your questions:

Quote:
I considered using functions for the operators but I'm rather new the iPhone SDK. Can you call functions from the ___viewcontroller.m file?
I'd use methods, but yes you can call functions and methods from any .m file.

Code:
Should you just add it before my IBActions function as a int functions? Inside the @implementation thing/block?
Yes, you declare methods in the @interface of your .h file and then write them in the @implementation of your .m file.
__________________

Free Games!
smasher is offline   Reply With Quote
Old 09-11-2010, 08:37 PM   #4 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by darkmist View Post
Anything? Any ideas? Even if you're clueless please say so because I feel alone.
Of course it's possible to call functions from a view controller.

It sounds like you need to write an equation parser.

You might do a google search on iPhone RPN calculator. RPN (Reverse Polish Notation) is pretty easy to implement, and I'm pretty sure I've seen one for iOS.

Writing your own equation parser is doable, but not a project for a beginning programmer.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 09-11-2010, 08:48 PM   #5 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 5
darkmist is on a distinguished road
Default

Quote:
Originally Posted by smasher View Post
No 'ffense, but it sounds like you're in the "hello world" phase and not ready for a project like this. I'd get a book, do some sample projects first. To your questions:



I'd use methods, but yes you can call functions and methods from any .m file.

Code:
Should you just add it before my IBActions function as a int functions? Inside the @implementation thing/block?
Yes, you declare methods in the @interface of your .h file and then write them in the @implementation of your .m file.
I know but this is a real thing that no one I talk to can figure out.
darkmist is offline   Reply With Quote
Old 09-11-2010, 08:51 PM   #6 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 5
darkmist is on a distinguished road
Thumbs up

Quote:
Originally Posted by Duncan C View Post
Of course it's possible to call functions from a view controller.

It sounds like you need to write an equation parser.

You might do a google search on iPhone RPN calculator. RPN (Reverse Polish Notation) is pretty easy to implement, and I'm pretty sure I've seen one for iOS.

Writing your own equation parser is doable, but not a project for a beginning programmer.
Thank you, I'll start with this.
darkmist is offline   Reply With Quote
Reply

Bookmarks

Tags
equation, operators, variable

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: 340
11 members and 329 guests
bignoggins, cgokey, givensur, hzwegjxg, iGamesDev, jenniead38, mraalex, PixelInteractive, raihan.zbr, Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

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