Question
I have a NSSlider that is attempting to convert a regular float into a CGFloat. The code that I am using:
CGFloat testing = [mainSlider floatValue];
However this simply makes the testing variable "0.00" when I attempt to log it.
NSLog(@"%f", testing);
Does anyone have any ideas as to why this would happen? Thanks for any help.
Solution
- check that mainSlider isn't nil
try this just in case (can't remember if CGFloat is a double or not):NSLog(@"%f", (double)testing);
Check that the variable isn't being shadowed like this:
CGFloat testing = 0.0; if(YES){ CGFloat testing = [mainSlider floatValue]; //should be: testing = [mainSlider floatValue]; } NSLog(@"testing = %f", testing); //this will print "testing = 0.000000"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow