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.
精彩评论