zoukankan      html  css  js  c++  java
  • 好用的一个object c 宏

    好用的一个object c 宏

    from https://github.com/justzt/ios-helper/blob/master/Macro.h

    //
    //  Macro.h
    //  PhotoWorld
    //
    //  Created by Yang on 10/5/11.
    //  Copyright 2011 __MyCompanyName__. All rights reserved.
    //
    
    #define SafeRelease(A) [A release];A=nil;
    #define SafeReleaseDelegate(A) [A setDelegate:nil];[A release];A=nil;
    
    #define StrFromFloat(F)     [NSString stringWithFormat: @"%f", F]
    #define StrFromInt(I)       [NSString stringWithFormat: @"%d", I]
    
    #define NumFromBOOL(B)      [NSNumber numberWithBool: B]
    #define NumFromInt(I)       [NSNumber numberWithBool: I]
    #define NumFromDouble(D)    [NSNumber numberWithDouble: D]
    
    #define FormatStr(fmt, ...) [NSString stringWithFormat:fmt, ##__VA_ARGS__]
    
    
    
    
    #define DLog(A) NSLog((@"%@(%d): %@"),[[NSString stringWithFormat:@"%s", __FILE__] lastPathComponent], __LINE__, A)
    #define DLogF(fmt, ...)  NSLog((@"%@(%d): " fmt),[[NSString stringWithFormat:@"%s", __FILE__] lastPathComponent], __LINE__, ##__VA_ARGS__)
    
    #define FirstObjectOfArray(A) ([A count]>0)?[A objectAtIndex: 0]:nil
    
    
    //debug stuff
    #define ShowCurrentPosition NSLog(@"
     Function: %s
     Pretty function: %s
     Line: %d
     File: %s
     Object: %@",__func__, __PRETTY_FUNCTION__, __LINE__, __FILE__, button)
    
    #define ShowCurrentLocation NSLog(@"Current selector: %@, Object class: %@, Filename: %@", NSStringFromSelector(_cmd), NSStringFromClass([self class]), [[NSString stringWithUTF8String:__FILE__] lastPathComponent])
    
    #define ShowStackSymbols NSLog(@"Stack trace: %@", [NSThread callStackSymbols])
    
    //dictionatry 取值NULL处理, 为空的话用给定的defultValue作为默认值
    #define DicValueForKey(dic,defultValue,key) [[dic objectForKey:key] class] ==  [NSNull class] ? defultValue : [dic objectForKey:key]
  • 相关阅读:
    C# Nest客户端查询es字段为空的语句
    Nuget 包还原成功,但引用异常
    ES7.2 安装问题
    elasticsearch 子节点有Unassigned Shards处理方法 和 failed to obtain in-memory shard lock
    rabbitmq修改日志级别
    C# NEST terms
    ES create index template
    Servicestack + Exceptionless本地部署
    live-server的使用
    处理cnpm控制台运行无反应(干瞪眼 就是不动)
  • 原文地址:https://www.cnblogs.com/likwo/p/3171307.html
Copyright © 2011-2022 走看看