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

bjomu

macrumors newbie
Original poster
Jun 23, 2008
2
0
Hello

When I'm trying to get the value of a UISlider Object, I always get the value 0.0, regardless, what the actual value is


-(IBAction)push: (id)sender // is called by pushing a Button
{
test = [slider value]; // Slider value should be 7.5

[label setText:[NSString stringWithFormat:mad:"%f",test]]; //label is an outlet to a label , 0.000 is printed out
}

When i type
test = 3.0;
instead of the value message, the correct value is printed out, so there has to be something wrong with the value property.

Another strange thing: when i want to "po test" in the console I get "Cannot access memory at address 0x0"

Edit: I forgot to say: test is a global float of my AppController class, of which the method push is part of.
 

Sbrocket

macrumors 65816
Jun 3, 2007
1,250
0
/dev/null
Did you set the minimumValue and maximumValue of the UISlider when you created it?

"po test" telling you "Cannot access memory at address 0x0" means you're trying to print something that is nil. How exactly did you declare test?
 

bjomu

macrumors newbie
Original poster
Jun 23, 2008
2
0
Thanks for your answer.

Yes, the minimum value is 3.0 and maximum is 9.0. So 7.5 should work.
I did declae test in the interface part of the AppController.h file like this:

float test;

That's why it is so strange, that it is supposed to be nil.
I have the same problem, when i set the value directly like

test = 3;

Then there is the same "cannot access" error for po, but test is NOT nil, because the label prints the correct value.

I'm really confused, this kind of stuff works perfectly for normal cocoa coding , but not for cocoa touch.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.