Git Product home page Git Product logo

cjamacros's Introduction

#CJA Macros Collection of daily used Macros in my iOS Projects

Build Status

##Installation Just drag&drop the CJAMarcos.h file in your XCode Project. For global usage you can import the CJAMarcos.h in your projects -Prefix.pch file.

##Usage First check out the example Project for further examples

//Should output the current function fingerprint
kNSLogFunction

//Should output the current function fingerprint + the given object description
kNSLogFunctionWithObject(@"My test log");
kNSLogFunctionWithObject(self);

//Use the Error Log to log statements in RELEASE mode
ErrorLog(@"Always print this");

//Localization Shortcut
NSString *localString = _(@"MyTestLocalizationStrinKey");
kNSLogFunctionWithObject(localString);

//Notification Shortcuts
static NSString *testNotificationName = @"TestNotificationName";

addObserver(testNotificationName, self, testNotification:, nil);

notify(testNotificationName, nil, nil);

removeObserver(self);

//Main thread shortcuts
onMainThread(
  //post a notification on the main thread
  kNSLogFunctionWithObject(@"This should be on the Main Thread");
  notify(@"NotificationOnMainThread", nil, nil);
);

//runtime system version checks
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO( _iOS_7_0) ) {
  kNSLogFunctionWithObject(@"Why are on iOS 7")
}

//you can always use the normal NSFoundationVersionNumber's
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO( NSFoundationVersionNumber_iOS_7_0)) {
  kNSLogFunctionWithObject(@"same runtime check as above")
}

if (SYSTEM_VERSION_LESS_THAN( _iOS_7_0) ) {
  kNSLogFunctionWithObject(@"We are on iOS 6, 5, 4, 3 or 2");
}

//Device Checks
if (DEVICE_IS_IPAD) {
	kNSLogFunctionWithObject(@"The current device is an iPad");
}

if (DEVICE_IS_IPHONE) {
	kNSLogFunctionWithObject(@"The current device is an iPhone (incl. iPhone 5 and iPod Touch's)");
}

if (DEVICE_IS_IPHONE_5) {
	kNSLogFunctionWithObject(@"The current device is an iPhone 5 or iPod Touch 5 Gen.");
}

//Declare Constants

//Defines a extern Constant, use it in your .h File
DEFINE_KEY(kTestKey)

//Assign a const value to the Constant, use it in your .m File
DECLARE_KEY(kTestKey)

//Assign a custom const value to the Constant, use it in your .m File
DEFINE_KEY_WITH_VALUE(kNewTestKey, @"CustomValue")

##License MIT License

cjamacros's People

Contributors

carlj avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.