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 07-04-2009, 03:36 AM   #1 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 26
Default String to Integer

I want to be able to add one number to another. One of my numbers is an integer, the other is a string in an editable text field. The only problem I have little knowledge of Xcode and do not know the function to turn a string into an integer. Also, when I build my app, I get an error that says "warning implicit declaration of function degreesToRadians", I have no idea why it is giving me this error. Here is my code:
Code:
drawingPoint1 = CGPointMake(drawingPoint.x+cos(degreesToRadians(angle1))*100,drawingPoint.y+sin(degreesToRadians(angle1))*100);
Thanks

Last edited by Gimples; 07-04-2009 at 04:27 AM.
Gimples is offline   Reply With Quote
Old 07-04-2009, 03:44 AM   #2 (permalink)
ftm
FasterThanMonkeys.com
 
Join Date: Mar 2009
Location: Southern California
Posts: 523
Send a message via AIM to ftm
Default

Code:
NSString *s = @"123";
int n = [s intValue];

That will do the conversion.
__________________


Website: http://fasterthanmonkeys.com

iScore Baseball Scorekeeper Top baseball scorekeeping app for iPhone
Bug Squash Reached #1 kids game in 15+ countries including USA, now with OpenFeint
Jam Packed! Fun puzzle game for all ages
Jam Packed Christmas Holiday puzzle game!
iScore Basketball Scorekeeper Best basketball scorekeeping application
ftm is offline   Reply With Quote
Old 07-04-2009, 04:31 AM   #3 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 26
Default

thanks, worked perfectly. Now I can't figure out why Xcode is saying I'm using degreedToRadians wrong...
Gimples is offline   Reply With Quote
Old 07-04-2009, 04:38 AM   #4 (permalink)
Registered Member
 
Join Date: Oct 2008
Location: London, UK
Posts: 249
Default

Where is that function defined? It's warning because there's no function declaration, but the fact that your code works means that it must be being included by a library somewhere. You probably just need to include a header file associated with that function.
__________________
Beard Booth HD - See what you'd look like with a beard today!

My iPhone Apps
My iPhone Tutorials
mattjgalloway is offline   Reply With Quote
Old 12-03-2009, 12:33 AM   #5 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 28
Default

Quote:
Originally Posted by Gimples View Post
I want to be able to add one number to another. One of my numbers is an integer, the other is a string in an editable text field. The only problem I have little knowledge of Xcode and do not know the function to turn a string into an integer. Also, when I build my app, I get an error that says "warning implicit declaration of function degreesToRadians", I have no idea why it is giving me this error. Here is my code:
Code:
drawingPoint1 = CGPointMake(drawingPoint.x+cos(degreesToRadians(angle1))*100,drawingPoint.y+sin(degreesToRadians(angle1))*100);
Thanks
At the top, before implementation, in .m file, paste the following lines to fix the warning

CGFloat degreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;};
CGFloat radiansToDegrees(CGFloat radians) {return radians * 180/M_PI;};
mohan.agadkar 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: 252
24 members and 228 guests
@sandris, AdamL, ADY, Dani77, diyora, FAED, fredidf, F_Bryant, GHuebner, HDshot, JasonR, mer10, Oral B, prchn4christ, Rudy, smithdale87, Speed, spiderguy84, stekki, tgjorgoski, Thompson22, Touchmint, twerner, vigu360
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,752
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:02 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0