Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C static method problem

Tags:

objective-c

I have a static method that should take two objects and a float as parameters. Everything is fine with the objects, but my float variable is lost. Here is a test case:

+ (void) someFunctionWithSomething: (xmlNodePtr *) node {
    CGFloat fsize = 0;
    if (fsize == 0) {
    fsize = 15.0f;
    }

    NSLog (@"size1: %f", fsize);    // output is 15.00000
    [MyClass getFontWithSize: fsize];
}

+ (void) getFontWithSize: (CGFloat) fsize {

    NSLog (@"size2: %f", fsize);    // output is 0.00000
}

How come my variable becomes zero all of a sudden? Could this be related to the fact that I am calling a static method from within a static method? I have a feeling that this is something really simple that I am missing here. Ideas?

like image 444
Shade Avatar asked Dec 13 '25 14:12

Shade


1 Answers

Check that your header file has a prototype for getFontWithSize that also matches your definition:

 +(void) getFontWithSize: (CGFloat) fsize;

Maybe you have something different there.

like image 109
Pablo Santa Cruz Avatar answered Dec 16 '25 22:12

Pablo Santa Cruz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!