判断是否为字符串、数组、字典
#define __IsStringValid(_str) (_str && [_str isKindOfClass:[NSString class]] && ([_str length] > 0))
#define __IsArrayValid(_array) (_array && [_array isKindOfClass:[NSArray class]] && ([_array count] > 0))
#define __IsDictionaryValid(__dic) (__dic && [__dic isKindOfClass:[NSDictionary class]] && ([__dic count] > 0))
判断是否继续、安全字符串(没有的为空)、weak_self
#ifndef guard
#define guard(CONDITION) \
if (CONDITION) {}
#endif
#ifndef SAFESTR
#define SAFESTR(x) ((x) ?: @"")
#endif
#ifndef WEAK_SELF
#define WEAK_SELF __weak typeof(self) __dg_weakSelf = self;
#endif
#ifndef STRONG_SELF
#define STRONG_SELF \
__strong typeof(__dg_weakSelf) self = __dg_weakSelf;
#endif
#ifndef STRONG_SELF_AND_RETURN_IF_NULL
#define STRONG_SELF_AND_RETURN_IF_NULL \
__strong typeof(__dg_weakSelf) self = __dg_weakSelf; \
if (!self) { return; }
#endif
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。