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-08-2011, 04:16 PM   #1 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 5
waychol is on a distinguished road
Default creating an exponent

I'm trying to get my application to change "x^2" to "x" with an exponent of 2. How would I go about that? Thanks!
waychol is offline   Reply With Quote
Old 09-08-2011, 04:19 PM   #2 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 241
MattW is on a distinguished road
Default

Quote:
Originally Posted by waychol View Post
I'm trying to get my application to change "x^2" to "x" with an exponent of 2. How would I go about that? Thanks!
Errr... huh?

You're going to need to provide more information if you want a response!
__________________

Highlight PDF text like no other app: iHighlight (now available for iPad and iPhone!)
-----
Create iPhone lists with no typing: Insta-List
-----
Make spelling fun, and create your own tests: iWillSpell
-----
A fast, elegant flashlight app: Insta-Light
-----


FourSixteen Productions
MattW is offline   Reply With Quote
Old 09-08-2011, 04:26 PM   #3 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 5
waychol is on a distinguished road
Default

Quote:
Originally Posted by MattW View Post
Errr... huh?

You're going to need to provide more information if you want a response!
Sorry. Well I'm trying to create an application that solves equations that will have buttons to enter in variables, numbers, and operations, but I can't figure out how to recognize the "^2" in "x^2" and change it to a power/exponent.
waychol is offline   Reply With Quote
Old 09-08-2011, 04:27 PM   #4 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

You could use the componentsSeparatedByString: method to split that into a base and an exponent.
smithdale87 is offline   Reply With Quote
Old 09-08-2011, 04:29 PM   #5 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

You may be looking for the pow() function, but it's not very clear from your post. EDIT: Disregard my post. You've made your intentions more clear, I replied without refreshing the page.

Last edited by baja_yu; 09-08-2011 at 04:32 PM.
baja_yu is offline   Reply With Quote
Old 09-08-2011, 04:39 PM   #6 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 5
waychol is on a distinguished road
Default

Quote:
Originally Posted by smithdale87 View Post
You could use the componentsSeparatedByString: method to split that into a base and an exponent.
but on the actual view, what I'd like is for the exponent entered to actually change to become a superscript
waychol is offline   Reply With Quote
Old 09-08-2011, 04:44 PM   #7 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

Ok, that makes sense. You should have said so in the first place..

Are you drawing the text on the screen yourself? or you are using a text field or text view?
smithdale87 is offline   Reply With Quote
Old 09-08-2011, 04:53 PM   #8 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 5
waychol is on a distinguished road
Default

Quote:
Originally Posted by smithdale87 View Post
Ok, that makes sense. You should have said so in the first place..

Are you drawing the text on the screen yourself? or you are using a text field or text view?
I have a textfield with buttons to input the variables (i.e. x,y,theta,r) and buttons to input the operations and numbers
waychol is offline   Reply With Quote
Old 09-08-2011, 04:53 PM   #9 (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 waychol View Post
but on the actual view, what I'd like is for the exponent entered to actually change to become a superscript
Unfortunately iOS does not support rich text. You can make an entire text field have attributes like bold, italics, superscript, subscript, a particular font, etc. However, you can't have a mix of normal and superscripted text in the same field.

The only ready-made UI component that will do this is a UIWebView, and that is a very heavy-weight object to use just to display styled text.

If you have fixed expressions like base^exponent, you could use a combination of different fields placed on the window at specific locations, using fixed text attributes, and then install strings into those pre-existing fields.

If you're trying to handle a more general case where you want to be able to display arbitrary formulas like polynomials using standard algebraic notation, it will be tricky. There is a low level framework called Core Text that will let you display text with different fonts, styles, and attributes, but using that to compose algebraic formulas would be a pretty big job.

You could also just slap a web view onto your screen and feed it formatted HTML to display.

Apple really needs to add formatted text support to iOS.
__________________
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
Reply

Bookmarks

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: 383
8 members and 375 guests
apatsufas, JackReidy, jeroenkeij, Sami Gh, tim0504, UMAD, yomo710, yuncarl28
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,672
Threads: 94,121
Posts: 402,904
Top Poster: BrianSlick (7,990)
Welcome to our newest member, yuncarl28
Powered by vBadvanced CMPS v3.1.0

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