#define or #if statement error
c-preprocessor, if-statement, objective-c
Solution
These are preprocessor directives, so you don't have access to [UIScreen mainScreen] methods and all other objects that are defined upon compilation!
Problem
I have read many definitions of # if and # define statement. I tried to use the way I read, but only with the error "Invalid token at start of a preprocessor expression" on the line that defines it as a comment below: ``` #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #define is_ipad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) #define is_ipad_hd ( (is_ipad == 1 && [UIScreen mainScreen].bounds.size.width > 1024 ) ? YES : NO) #define is_iphone_hd ([UIScreen mainScreen].bounds.size.width > 480 ? YES : NO) #define device_width 480.0f #define device_height 320.0f #if (is_ipad_hd == YES) // Error here #define device_width = 2048.0f #define device_height = 1496.0f #endif ``` Why it works in simple tutorials and when we try something more complex these things happen!