I would like to define a number of variables that I will use in view controllers to set font size depending on whether the user is on an iphone or an ipad. So far I can define, say, a global float no problem. However, I am not able to include any conditional statements in my file. This works fine:
.h file:
#import <Foundation/Foundation.h>
@interface GlobalDeclarations : NSObject
extern float MyGlobalVariable;
@end
.m file:
#import "GlobalDeclarations.h"
@implementation GlobalDeclarations
float MyGlobalVariable = 0.0f;
@end
But I cannot modify my .m file to include any if statement at all - I always get the same error:
"expected idenitifer or ')'
For example, this version of the .m file produces the above error:
#import "GlobalDeclarations.h"
@implementation GlobalDeclarations
float MyGlobalVariable = 0.0f;
if(MyGlobalVariable > 2.0f)
{
NSLog(@"inside if statement");
}
@end
I get the error even if I just write something like if(TRUE)...
How can I conditionally define globals in an attachment like this? What is wrong with the if-statement? Thanks for any suggestions.