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

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

Draw This
($0.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 08-08-2009, 08:07 PM   #10 (permalink)
Frankie
Registered Member
 
Frankie's Avatar
 
Join Date: Jun 2009
Location: San Antonio, TX
Posts: 104
Frankie is on a distinguished road
Send a message via MSN to Frankie
Talking

Quote:
Originally Posted by BrianSlick View Post
How have you done anything at all without knowing what NSLog is?

Ok, your screen shots are not appearing, so you'll need to host them somewhere else probably. I'm going to make a couple of guesses, but without seeing exactly what the problem is, it's a bit tough to be certain.

So, first of all, this line appears to be what sets the text for what I assume is a label or a text field:
Code:
tipAmount.text = [NSString stringWithFormat:@"Tip Level: %.2f%", tipTotal];
Are you literally seeing "..." or are you seeing "Tip Level: ..."? Please be specific.

Next, in order to find out if the issue is with the data or the display of the data, do something like this:

Code:
float tipTotal = tipSelected * 3.8 / [billTotal.text floatValue]; 
NSLog(@"tipTotal is: %f", tipTotal);
tipAmount.text = [NSString stringWithFormat:@"Tip Level: %.2f%", tipTotal];
View the log as you run your program. If this line produces the correct answer, then the issue is with the display of your data. If it doesn't, then your data is wrong.

Next, verify for your code. For example:
Code:
tipSelected = tipSelected;
This does nothing. Did you forget a + 1 or something? No idea what this was supposed to be, but as is it doesn't do anything.

Next, you need to be aware that special characters do certain things, especially the % sign. So when you are doing %d for an integer, or %f as you are here for the float, that % means something special. Because of that, you can't just stick a % in there and have it display as text. It is special, so you have to treat it as special. In this case, you have do to a double %% in order to get the display to be what you want (assuming you want something like 2.50% to appear). So your stringWithFormat line actually needs to look like:

Code:
tipAmount.text = [NSString stringWithFormat:@"Tip Level: %.2f%%", tipTotal];
Now I tested it as you have it here, and I never saw "..." in the log. I just saw the number without the % sign. So if you make the code changes I've indicated here, and you've verified that your data is correct, and it still isn't displaying correctly, then I still think that your label is too small. Make it bigger.
OMFG, You were right!!!! I effing love you.

My label was too small!!!! Now i feel retarded

Thank you a thousand times!!!!!
__________________
My new app that was recently featured in the App Store section: Soundsations
Creator of the most awesome app iWasted
Also Created the Audience app
Frankie is offline   Reply With Quote
 

» Advertisements
» Online Users: 786
25 members and 761 guests
ADY, and1, apatsufas, Brandt, BrianSlick, Cnmcc, cucuru, dacapo, Duncan C, frostmane, gbenna, iekei, ilmman, iphonedevtechnew, linkmx, mikel888, NetGuru, speck, speed4mee, Steven.C, taylor202, Thompson22, thorep, ukneeq, varchar
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,022
Threads: 93,865
Posts: 401,926
Top Poster: BrianSlick (7,963)
Welcome to our newest member, mikel888
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:54 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.