Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ArtOfWarfare

macrumors G3
Original poster
Nov 26, 2007
9,558
6,058
timeRemaining is a float,
timeRemainingLabel is a UILabel,
roundTime is a UITextField,

all 3 are declared in my header.

I'm getting errors with these two lines of code...

Code:
timeRemaining = roundTime.text;
I have no idea how to convert a NSString to a float... I was crossing my fingers this would work... apparently it didn't as I got this error

error: incompatible types in assignment

Code:
timeRemainingLabel.text = (@"Time Remaining: %f Seconds", timeRemaining);

I was actually expecting this one to work... I thought it would work just like in C where %f would be replaced with timeRemaining. Apparently not because I got this error
error: incompatible type of argument 1 of 'setText:'

Well... at least I havn't had the same problem twice yet... it's a sign I'm learning from my mistakes, right? Good judgement comes from experience; experience comes from bad judgement.

Thanks for all the help people have been giving, and thanks in advance for help with this too.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Did you even open the documentation? In the time it took you to type that you could have found the floatValue method of NSString.

As for turning floats into NSStrings you have a few options. The closest to what you have posted (which makes no sense at all, are you expecting the compiler to magically turn that into a method call for you) is also clear in the documentation: the convenience stringWithFormat: factory method.
 

ArtOfWarfare

macrumors G3
Original poster
Nov 26, 2007
9,558
6,058
Sorry, I did check the documentation but I didn't understand how to use stringWithFormat properly.

Thanks detz for giving an example of how to use stringWithFormat.

And thanks robbieducan for pointing out the method I overlooked... floatValue.

It works now... although my timer doesn't seem to be working properly... hopefully I can fix that without asking for help on the forums...

Edit: Now the timer works. Just for the record... if you're making a timer that repeats every 0.01 seconds... you shouldn't make it send a message to the NSLog every time...
 

aaronvegh

macrumors newbie
Dec 1, 2001
17
0
Did you even open the documentation? In the time it took you to type that you could have found the floatValue method of NSString.

As for turning floats into NSStrings you have a few options. The closest to what you have posted (which makes no sense at all, are you expecting the compiler to magically turn that into a method call for you) is also clear in the documentation: the convenience stringWithFormat: factory method.

That doesn't make you any less of a jackass. Some people don't have the knowledge you do, so please, cut them some slack. Detz's concise response was exactly what I was Googling for.
 

ArtOfWarfare

macrumors G3
Original poster
Nov 26, 2007
9,558
6,058
That doesn't make you any less of a jackass. Some people don't have the knowledge you do, so please, cut them some slack. Detz's concise response was exactly what I was Googling for.

No, he was completely right. I'd become too dependent on asking people for help rather than taking the time to check the documentation. Don't call him names just for pointing out my flaws... how else would people learn they were doing things wrong? Their ego will tell them they're doing it right so they'll have to have someone else tell them they're wrong.

HI
can you help me that i can write a sample code for a login page with 2 field user and pass and a button for submit .
Thanks.
have you a good document that explain code?

This seems rather off topic but if you check the ADC page I'm pretty sure that one is anwsered in the FAQ...

http://developer.apple.com/iphone/gettingstarted/docs/gettingstartedfaq.action

I'm not going to give you the exact answer... instead I'll let you learn how to check the adc documentation to find answers yourself.
 

Sbrocket

macrumors 65816
Jun 3, 2007
1,250
0
/dev/null
That doesn't make you any less of a jackass. Some people don't have the knowledge you do, so please, cut them some slack. Detz's concise response was exactly what I was Googling for.

aaronvegh -

People answering questions here sometimes come off as rude because the questions asked in those cases are typically rudimentary, with answers that could be readily obtained from a quick search through Apple's doc sets. Using documentation is a key skill that less knowledgeable or developers that are just starting out will find it in their best interest to develop should they want to avoid relying on others to answer every simple question (and probably getting a snappy answer in reply.)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.