复杂写法的宏
来源:互联网 发布:晚会暖场小游戏知乎 编辑:程序博客网 时间:2024/05/16 05:18
// Some simple defines to make life easier on ourself
#if TARGET_OS_IPHONE
#define MakeColor(r, g, b) [UIColor colorWithRed:(r/255.0f) green:(g/255.0f) blue:(b/255.0f) alpha:1.0f]
#else
#define MakeColor(r, g, b) [NSColor colorWithCalibratedRed:(r/255.0f) green:(g/255.0f) blue:(b/255.0f) alpha:1.0f]
#endif
#if TARGET_OS_IPHONE
#define OSColor UIColor
#else
#define OSColor NSColor
#endif
// If running in a shell, not all RGB colors will be supported.
// In this case we automatically map to the closest available color.
// In order to provide this mapping, we have a hard-coded set of the standard RGB values available in the shell.
// However, not every shell is the same, and Apple likes to think different even when it comes to shell colors.
#if TARGET_OS_IPHONE
#define MakeColor(r, g, b) [UIColor colorWithRed:(r/255.0f) green:(g/255.0f) blue:(b/255.0f) alpha:1.0f]
#else
#define MakeColor(r, g, b) [NSColor colorWithCalibratedRed:(r/255.0f) green:(g/255.0f) blue:(b/255.0f) alpha:1.0f]
#endif
#if TARGET_OS_IPHONE
#define OSColor UIColor
#else
#define OSColor NSColor
#endif
// If running in a shell, not all RGB colors will be supported.
// In this case we automatically map to the closest available color.
// In order to provide this mapping, we have a hard-coded set of the standard RGB values available in the shell.
// However, not every shell is the same, and Apple likes to think different even when it comes to shell colors.
//
// 参考写法
#define LOG_LEVEL2
#define NSLogError(frmt, ...) do{ if(LOG_LEVEL >=1) NSLog((frmt), ##__VA_ARGS__); } while(0)
#define NSLogWarn(frmt, ...) do{ if(LOG_LEVEL >= 2) NSLog((frmt), ##__VA_ARGS__); } while(0)
#define NSLogInfo(frmt, ...) do{ if(LOG_LEVEL >= 3) NSLog((frmt), ##__VA_ARGS__); } while(0)
#define NSLogError(frmt, ...) do{ if(LOG_LEVEL >=1) NSLog((frmt), ##__VA_ARGS__); } while(0)
#define NSLogWarn(frmt, ...) do{ if(LOG_LEVEL >= 2) NSLog((frmt), ##__VA_ARGS__); } while(0)
#define NSLogInfo(frmt, ...) do{ if(LOG_LEVEL >= 3) NSLog((frmt), ##__VA_ARGS__); } while(0)
#define NSLogVerbose(frmt, ...) do{ if(LOG_LEVEL >=4) NSLog((frmt), ##__VA_ARGS__); } while(0)
#define LOG_MACRO(isAsynchronous, lvl, flg, ctx, atag, fnct, frmt, ...) \
[DDLog log:isAsynchronous \
level:lvl \
flag:flg \
context:ctx \
file:__FILE__ \
function:fnct \
line:__LINE__ \
tag:atag \
[DDLog log:isAsynchronous \
level:lvl \
flag:flg \
context:ctx \
file:__FILE__ \
function:fnct \
line:__LINE__ \
tag:atag \
format:(frmt), ##__VA_ARGS__]
//判断区分的宏的写法
#if TARGET_IPHONE_SIMULATOR
#define XATTR_ARCHIVED_NAME @"archived"
#else
#define XATTR_ARCHIVED_NAME @"lumberjack.log.archived"
#define XATTR_ARCHIVED_NAME @"archived"
#else
#define XATTR_ARCHIVED_NAME @"lumberjack.log.archived"
#endif
#ifndef NSXMLElementDeclarationKind
#define NSXMLElementDeclarationKind DDXMLElementDeclarationKind
#endif
#ifndef NSXMLNotationDeclarationKind
#define NSXMLNotationDeclarationKind DDXMLNotationDeclarationKind
#define NSXMLElementDeclarationKind DDXMLElementDeclarationKind
#endif
#ifndef NSXMLNotationDeclarationKind
#define NSXMLNotationDeclarationKind DDXMLNotationDeclarationKind
#endif
// The debugging macro adds a significant amount of overhead, and should NOT be enabled on production builds.
#if DEBUG
#define DDXML_DEBUG_MEMORY_ISSUES 0
#else
#define DDXML_DEBUG_MEMORY_ISSUES 0 // Don't change me!
#if DEBUG
#define DDXML_DEBUG_MEMORY_ISSUES 0
#else
#define DDXML_DEBUG_MEMORY_ISSUES 0 // Don't change me!
#endif
- (void)inDatabase:(void(^)(FMDatabase*db))block {
/* Get the currently executing queue (which should probably be nil, but in theory could be another DB queue
* and then check it against self to make sure we're not about to deadlock. */
FMDatabaseQueue *currentSyncQueue = (__bridgeid)dispatch_get_specific(kDispatchQueueSpecificKey);
assert(currentSyncQueue !=self&& "inDatabase: was called reentrantly on the same queue, which would lead to a deadlock");
FMDBRetain(self);
dispatch_sync(_queue, ^() {
FMDatabase *db = [selfdatabase];
block(db);
if ([dbhasOpenResultSets]) {
NSLog(@"Warning: there is at least one open result set around after performing [FMDatabaseQueue inDatabase:]");
#if defined(DEBUG) && DEBUG
NSSet*openSetCopy =FMDBReturnAutoreleased([[db valueForKey:@"_openResultSets"] copy]);
for (NSValue*rsInWrappedInATastyValueMealin openSetCopy) {
FMResultSet *rs = (FMResultSet*)[rsInWrappedInATastyValueMealpointerValue];
NSLog(@"query: '%@'", [rsquery]);
}
#endif
}
});
FMDBRelease(self);
}
/* Get the currently executing queue (which should probably be nil, but in theory could be another DB queue
* and then check it against self to make sure we're not about to deadlock. */
FMDatabaseQueue *currentSyncQueue = (__bridgeid)dispatch_get_specific(kDispatchQueueSpecificKey);
assert(currentSyncQueue !=self&& "inDatabase: was called reentrantly on the same queue, which would lead to a deadlock");
FMDBRetain(self);
dispatch_sync(_queue, ^() {
FMDatabase *db = [selfdatabase];
block(db);
if ([dbhasOpenResultSets]) {
NSLog(@"Warning: there is at least one open result set around after performing [FMDatabaseQueue inDatabase:]");
#if defined(DEBUG) && DEBUG
NSSet*openSetCopy =FMDBReturnAutoreleased([[db valueForKey:@"_openResultSets"] copy]);
for (NSValue*rsInWrappedInATastyValueMealin openSetCopy) {
FMResultSet *rs = (FMResultSet*)[rsInWrappedInATastyValueMealpointerValue];
NSLog(@"query: '%@'", [rsquery]);
}
#endif
}
});
FMDBRelease(self);
}
//判断含警告
#if ! __has_feature(objc_arc)
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif
0 0
- 复杂写法的宏
- 绑定数据的一些复杂写法
- silverlight的Datagrid的超复杂表头写法
- 关于数据仓库中复杂报表SQL语句的写法
- Android 复杂的列表视图新写法 MultiType
- android 复杂的列表视图新写法MultiType
- Android使用AIDL时传递复杂数据对象的写法
- 程序复杂条件分支逻辑的一种写法(js)
- 一复杂存储过程写法!
- Yii createComand()稍复杂写法
- 一个复杂引用的实例『只可以作为参考,此程序写法不推荐』
- 《Android 复杂的列表视图新写法 · 详解篇》多条目
- Android 复杂的多类型列表视图新写法:MultiType 3.0
- 一些宏的写法
- 复杂sql语句proc写法(动态写法)
- 跨平台宏的写法
- 较复杂的宏操作符
- 一个复杂宏定义的解读
- iOS版PhoneGap原理分析
- android-Fragment
- Hybrid选型和PhoneGap开发环境搭建
- 安装PHP运行环境时候vcruntime140.dll问题的解决方法
- 约瑟夫报数出列题
- 复杂写法的宏
- UVA 10881 思维
- 1秒钟检查一次记事本进程,没有记事本就启动记事本
- 单例宏
- 颜色设置的宏定义
- iOS 的 XMPPFramework 简介
- 《leetCode》:Reverse Linked List II
- XMPP协议实现原理介绍
- android canvas详解