开发者

Objective-C static method problem

I have a static method that should take two objects and a float as parameters. Everything is fine with the object开发者_如何学JAVAs, 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜