Joined August 2013
·

Alok kumar singh

jaipur , rajasthan
·
·

Posted to Some useful iOS Macros over 1 year ago

define METHODNAME [NSString stringWithFormat : @ "%s", _PRETTYFUNCTION_]

define OBSERVATIONPOINT NSLog(@ "\n%@ EXECUTED upto %d\n", METHODNAME, LINE);

//////////////////////ADVANCED TRY CATCH SYSTEM////////////////////////////////////////

ifndef UseTryCatch

define UseTryCatch 1

ifndef UsePTMName

define UsePTMName 0 //USE 0 TO DISABLE AND 1 TO ENABLE PRINTING OF METHOD NAMES WHERE EVER TRY CATCH IS USED

if UseTryCatch

if UsePTMName

define TCSTART @try { NSLog(@ "\n%@\n", METHOD_NAME);

else

define TCSTART @try {

endif

define TCEND } @catch (NSException *e) { NSLog(@ "\n\n\n\n\n\n\

\n\n|EXCEPTION FOUND HERE...PLEASE DO NOT IGNORE\
\n\n|FILE NAME %s\
\n\n|LINE NUMBER %d\
\n\n|METHOD NAME %@\
\n\n|EXCEPTION REASON %@\
\n\n\n\n\n\n\n", strrchr(FILE, '/'), LINE, METHOD_NAME, e); };

else

define TCSTART {

define TCEND }

endif

endif

endif

//////////////////////ADVANCED TRY CATCH SYSTEM////////////////////////////////////////

if 0

define NSLog //NSLog

endif

define ISIPAD (UIUSERINTERFACEIDIOM() == UIUserInterfaceIdiomPad)

define ISIPHONE (UIUSERINTERFACEIDIOM() == UIUserInterfaceIdiomPhone)

define ISIPHONE5 (fabs((double)[[UIScreen mainScreen] bounds].size.height - (double)568) < DBL_EPSILON)

define NAVIGATIONBARHEIGHT 44

//THROUGH OUT THE APPLICATION I AM USING showDebuggingMessage METHOD OF Aksmethods class for the purpose of debugging
//if ENABLED it will display some important status via popup messages

define SHOWDEBUGGINGMESSAGE FALSE

define SCREENFRAMERECT [[UIScreen mainScreen] bounds]

define APPDELEGATE ((AppDelegate *)[[UIApplication sharedApplication] delegate])

define HIDENETWORKACTIVITY_INDICATOR [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible : NO];

define SHOWNETWORKACTIVITY_INDICATOR [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible : YES];

define RETURNIFTHISVIEWISNOTATOPVIEWCONTROLLER if (self.navigationController) if (!(self.navigationController.topViewController == self)) return;

//macros for ios 6 orientation support

ifndef ORIENTATIONSUPPORTLANDSCAPERIGHT_ONLY

define ORIENTATIONSUPPORTLANDSCAPERIGHT_ONLY \

  • (BOOL)shouldAutorotate { \ return NO; \ } \ -(NSUInteger)supportedInterfaceOrientations { \ return UIInterfaceOrientationMaskLandscapeRight; \ }

endif

ifndef ORIENTATIONSUPPORTPORTRAIT_ONLY

define ORIENTATIONSUPPORTPORTRAIT_ONLY \

  • (BOOL)shouldAutorotate { \ return NO; \ } \ -(NSUInteger)supportedInterfaceOrientations { \ return UIInterfaceOrientationMaskPortrait; \ }

endif

define SHOWSTATUSBAR [[UIApplication sharedApplication] setStatusBarHidden : NO withAnimation : UIStatusBarAnimationNone];

define HIDESTATUSBAR [[UIApplication sharedApplication] setStatusBarHidden : YES withAnimation : UIStatusBarAnimationNone];

define SHOWNAVIGATIONBAR [self.navigationController setNavigationBarHidden : FALSE];

define HIDENAVIGATIONBAR [self.navigationController setNavigationBarHidden : TRUE];

define CURRENTDEVICEVERSION_FLOAT [[UIDevice currentDevice] systemVersion].floatValue

define CURRENTDEVICEVERSION_STRING [[[NSBundle mainBundle] infoDictionary] objectForKey : @ "CFBundleVersion"]

define FONT_REGULAR @ "Solomon"

define FONT_HEAVY @ "Solomon-Heavy"

define FONT_BOLD @ "Solomon-Bold"

define IOSSTANDARDCOLOR_BLUE [UIColor colorWithHue : 0.6 saturation : 0.33 brightness : 0.69 alpha : 1]

define CLEARNOTIFICATIONBADGE [UIApplication sharedApplication].applicationIconBadgeNumber = 0;

define CLEARXCODECONSOLE NSLog(@ "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");

define DATEFORMATUSED @"yyyy'-'MM'-'dd' 'HH':'mm':'ss"

define VC_OBJ(x) [[x alloc] init]

define VCOBJWITH_NIB(x) [[x alloc] initWithNibName:(NSString *)CFSTR(#x) bundle:nil]

Achievements
59 Karma
0 Total ProTip Views