Objective-C static method problem

I have a static method that should take two objects and a float as parameters. Everything is fine with 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
}

Why does my variable suddenly become null? Could this be due to the fact that I'm calling a static method from a static method? I have a feeling that this is something very simple, which I miss here. Ideas?

+3
source share
1 answer

Make sure your header file has a prototype for getFontWithSize, which also matches your definition:

 +(void) getFontWithSize: (CGFloat) fsize;

Perhaps you have something else there.

+1
source

All Articles