Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.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-05-2009, 02:44 PM   #1 (permalink)
New Member
 
Join Date: Mar 2009
Posts: 44
Default Really quick help

The string below always stores Object1x as "0" even if item1Obj.center.x is 200 or 300. Does anyone have any idea whats going wrong?
Quote:
NSString *title = [[NSString alloc] initWithFormat: @"Object1x=%d", item1Obj.center.x];
soku is offline   Reply With Quote
Old 07-05-2009, 02:55 PM   #2 (permalink)
high school developer
 
Join Date: Jul 2009
Posts: 62
Default

Quote:
Originally Posted by soku View Post
The string below always stores Object1x as "0" even if item1Obj.center.x is 200 or 300. Does anyone have any idea whats going wrong?
it should be %f not %d. this same thing happened to me and when I changed it to this it worked. its because cgpoint is made up of two cgfloats (x and y) and the string format thingy is %f for floats. oh ya and also you don't need to allocate and initialize nsstrings. they are autorelease so you can just change your code to this:

Code:
NSString *title = [NSString stringWithFormat:@"Object1x=%f", item1Obj.center.x];

Last edited by anonymous; 07-05-2009 at 02:57 PM.
anonymous is offline   Reply With Quote
Old 07-05-2009, 02:58 PM   #3 (permalink)
New Member
 
Join Date: Mar 2009
Posts: 44
Default

Quote:
Originally Posted by anonymous View Post
it should be %f not %d. this same thing happened to me and when I changed it to this it worked. its because cgpoint is made up of two cgfloats (x and y) and the string format thingy is %f for floats.
Great! Thanks, I expected it would be the %d which is why I didn't post the rest of my code. Thanks once again.
soku 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


Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 23,944
Threads: 38,724
Posts: 169,931
Top Poster: smasher (2,554)
Welcome to our newest member, mickeyargo
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:24 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0