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 02-24-2010, 05:49 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 157
Default UILabel and NSString and floats...

I have an app that starts in a table view, then loads the same page no matter which cell you choose.

That window then loads different numbers from my appdelegate, based on which cell you selected. For a rough example...

In my delegate
Code:
float address1;
float personselect;
In my rootviewcontroller
Code:
mainDelegate.personselect = indexPath.row +1;
In profileviewcontroller (this is what I'm trying to do)
Code:
NSString *tempstring = [NSString stringWithFormat:@"mainDelegate.address%.f", mainDelegate.playerselect];

[adresslabel setText:[NSString stringWithFormat:@"%.f", tempstring]];

So basically, I'm displaying a float that depends on a float, and I absolutely can not write out all of the if/then statements for it.

I obviously haven't gotten this to work, if there's anybody that understands what I'm trying to do and can help, I would highly appreciate it. thanks.
__________________
Check out our Apps!
Boxen4Oxen
VisCenter

Film Budget

Everwell TV

Last edited by starwarsdevwookie59; 02-24-2010 at 08:24 PM.
starwarsdevwookie59 is offline   Reply With Quote
Old 02-24-2010, 06:11 PM   #2 (permalink)
Registered Member
 
Join Date: May 2009
Location: Denver CO
Posts: 88
Default

I think part of the issue is that the placeholder for a float should have a decimal inside it relating to the number of digits before and after the decimal point. such as %.3f would print however many before the decimal, and 3 digits after.

I'm pretty sure this is how it goes. If I am wrong, I apologize. But this is how it works for me, so just passing it along.
seriessix is offline   Reply With Quote
Old 02-24-2010, 06:24 PM   #3 (permalink)
Pro. Game Developer
iPhone Dev SDK Supporter
 
Join Date: Feb 2009
Location: żLa Islas Hermosas?
Posts: 2,178
Default

Quote:
Originally Posted by starwarsdevwookie59 View Post
I have an app that starts in a table view, then loads the same page no matter which cell you choose.

That window then loads different numbers from my appdelegate, based on which cell you selected. For a rough example...

In my delegate
Code:
float *address1;
float *personselect;
In my rootviewcontroller
Code:
mainDelegate.personselect = indexPath.row +1;
In profileviewcontroller (this is what I'm trying to do)
Code:
NSString *tempstring = [NSString stringWithFormat:@"mainDelegate.address%.f", mainDelegate.playerselect];

[adresslabel setText:[NSString stringWithFormat:@"%.f", tempstring]];

So basically, I'm displaying a float that depends on a float, and I absolutely can not write out all of the if/then statements for it.

I obviously haven't gotten this to work, if there's anybody that understands what I'm trying to do and can help, I would highly appreciate it. thanks.
The first thing that jumps out at me is this declaration:
Code:
float *address1;
float *personselect;
The float type is a C intrinsic type, and when you want a float member in your class, it isn't normally declared as a pointer. I suspect the issue is that your declaration should look like this:
Code:
float address1;
float personselect;
I didn't really look at the rest of your code, so I'm sure if changing this will completely fix your problem.
__________________
~~ Word Flurry ~~ App Store / Website / Facebook
Kalimba is offline   Reply With Quote
Old 02-24-2010, 06:41 PM   #4 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 157
Default

I apologize... this is just a rough mockup of what I'm trying to do, I didn't mean to make those errors.

The code that puts the floats in the labels is all I am worried about. I just provided the other codes to show what I was working with.

Sorry.

Basically, I want to make the UILabel's text the value of mainDelegate.address@"%.f", mainDelegate.personselect.
__________________
Check out our Apps!
Boxen4Oxen
VisCenter

Film Budget

Everwell TV

Last edited by starwarsdevwookie59; 02-25-2010 at 09:54 AM.
starwarsdevwookie59 is offline   Reply With Quote
Reply

Bookmarks

Tags
float, label, nsstring, string, uilabel

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: 260
20 members and 240 guests
2WeeksToGo, ADY, BrianSlick, dacapo, Dani77, Dattee, Duncan C, headkaze, IphoneSdk, jemicha, kapps11, mer10, mgon987, Punkjumper, sneaky, timle8n1
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,879
Threads: 89,228
Posts: 380,743
Top Poster: BrianSlick (7,129)
Welcome to our newest member, mgon987
Powered by vBadvanced CMPS v3.1.0

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