
1. __deprecated_msg
-(void)function __deprecated_msg(“这是一个废弃的方法”);
2. NS_REQUIRES_SUPER
在自定义的方法后面加上这个, 其子类在重写这个方法时候, 必须调用父类的这个方法, 不然会警告或者直接报错.
3. NS_ASSUME_NONNULL_BEGIN + NS_ASSUME_NONNULL_END
取消pointer is missing a nullability type specifier(_Nonnull, _Nullable, or _Null_unspecified)警告
4. #ifdef DEBUG
#define NSLog(format, …) NSLog((@”%s-%d:” format), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
#define NSLog(FORMAT, …) fprintf(stderr,”%s:%dt%sn”,[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#endif
用于定位log的位置,后者可以去掉时间显示
5. #ifdef Test
doSomeThing;
#endif
在target的Preprocessor Macros中定义,可以用来build多个不同功能的target
6.strongweak宏定义
# define LYWeakSelf(type) __weak typeof(type) weak##type = type;
# define LYStrongSelf(type) __strong typeof(type) type = weak##type;




近期评论