Skip to content

Instantly share code, notes, and snippets.

@carlj
Last active December 21, 2015 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlj/6269897 to your computer and use it in GitHub Desktop.
Save carlj/6269897 to your computer and use it in GitHub Desktop.
my "all i use makros"
//
// Makro.h
//
// Created by Carl Jahn
// Copyright (c) 2013 Carl Jahn. All rights reserved.
//
#import <Foundation/Foundation.h>
//NSLogs
#define kNSLogFunctionWithObject(_object) NSLog(@"%s %@", __FUNCTION__, [_object description]);
#define kNSLogFunction kNSLogFunctionWithObject(@"")
#ifdef DEBUG
#else
#define NSLog(format, ...)
#endif
//Localisation
#define _(_key) NSLocalizedString( _key , nil)
//NSNotifications
#define notify(notificationName, obj, userInfoDictionary) [[NSNotificationCenter defaultCenter] postNotificationName: notificationName object: obj userInfo: userInfoDictionary]
#define addObserver(notificationName, observer, observerSelector) [[NSNotificationCenter defaultCenter] addObserver:observer selector:@selector(observerSelector) name:notificationName object:nil]
#define removeObserver(observer) [[NSNotificationCenter defaultCenter] removeObserver: observer]
//Perform on Main Thread
#define onMainThread(lambda) \
if([NSThread isMainThread]){ \
lambda \
} else { \
dispatch_async(dispatch_get_main_queue(), ^{ \
lambda \
}); \
}
//
#define IS_WIDESCREEN ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
//Runtime iOS Version check
#ifndef NSFoundationVersionNumber_iOS_5_0
#define NSFoundationVersionNumber_iOS_5_0 881.00
#define _iOS_5_0 NSFoundationVersionNumber_iOS_5_0
#endif
#ifndef NSFoundationVersionNumber_iOS_5_1
#define NSFoundationVersionNumber_iOS_5_1 890.10
#define _iOS_5_1 NSFoundationVersionNumber_iOS_5_1
#endif
#ifndef NSFoundationVersionNumber_iOS_6_0
#define NSFoundationVersionNumber_iOS_6_0 993.00
#define _iOS_6_0 NSFoundationVersionNumber_iOS_6_0
#endif
#ifndef NSFoundationVersionNumber_iOS_6_1
#define NSFoundationVersionNumber_iOS_6_1 993.00
#define _iOS_6_1 NSFoundationVersionNumber_iOS_6_1
#endif
#ifndef NSFoundationVersionNumber_iOS_7_0
#define NSFoundationVersionNumber_iOS_7_0 1047.00
#define _iOS_7_0 NSFoundationVersionNumber_iOS_7_0
#endif
#define SYSTEM_VERSION_EQUAL_TO(_v) ( floor(NSFoundationVersionNumber) == _v ? YES : NO )
#define SYSTEM_VERSION_GREATER_THAN(_v) ( floor(NSFoundationVersionNumber) > _v ? YES : NO )
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(_v) ( floor(NSFoundationVersionNumber) >= _v ? YES : NO )
#define SYSTEM_VERSION_LESS_THAN(_v) ( floor(NSFoundationVersionNumber) < _v ? YES : NO )
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(_v) ( floor(NSFoundationVersionNumber) <= _v ? YES : NO )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment