Created
November 12, 2011 02:03
-
-
Save nowsprinting/1359898 to your computer and use it in GitHub Desktop.
prefix.pch (includes logging macro) for iOS project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Availability.h> | |
#ifndef __IPHONE_3_0 | |
#warning "This project uses features only available in iPhone SDK 3.0 and later." | |
#endif | |
#ifdef __OBJC__ | |
#import <Foundation/Foundation.h> | |
#import <UIKit/UIKit.h> | |
#import <CoreData/CoreData.h> | |
#endif | |
#if TARGET_IPHONE_SIMULATOR | |
#import <objc/objc-runtime.h> | |
#else | |
#import <objc/runtime.h> | |
#endif | |
//Logging macro | |
#ifdef DEBUG | |
#define LOG(fmt, ...) NSLog((@"%s(%d) " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); | |
#else | |
#define LOG(fmt, ...) ; | |
#endif | |
//Logging ClassName | |
#define LOG_CLASSNAME(object) LOG(@"%s", class_getName([object class])); | |
//Logging Frame | |
#define LOG_FRAME(frame) LOG(@"x=%1.0f, y=%1.0f, w=%1.0f, h=%1.0f", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height); | |
//Performance measurement | |
#define MEASURE_BEGIN struct timeval start, stop; gettimeofday(&start, NULL); | |
#define MEASURE_STAMP gettimeofday(&stop, NULL); LOG(@"time: %f[usec]\n", ((stop.tv_sec*1000000+stop.tv_usec) - (start.tv_sec*1000000+start.tv_usec))/1000000.0f); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment