快速開發(fā)經(jīng)驗(yàn)匯總小結(jié)(洪)

//字符串是否為空

#define YStringEmpty(str) ([str isKindOfClass:[NSNull class]] || str == nil || [str length] < 1 ? YES : NO )

//數(shù)組是否為空

#define YArrayEmpty(array) (array == nil || [array isKindOfClass:[NSNull class]] || array.count == 0)

//字典是否為空

#define YDictEmpty(dic) (dic == nil || [dic isKindOfClass:[NSNull class]] || dic.allKeys == 0)

//是否是空對(duì)象

#define YObjectIsEmpty(_object) (_object == nil \

||[_objectisKindOfClass:[NSNullclass]]\

||([_objectrespondsToSelector:@selector(length)]&&[(NSData*)_objectlength]==0)\

||([_objectrespondsToSelector:@selector(count)]&&[(NSArray*)_objectcount]==0))

//一些縮寫

#define YApplication????????[UIApplication sharedApplication]

#define YKeyWindow??????????[UIApplication sharedApplication].keyWindow

#define YAppDelegate????????[UIApplication sharedApplication].delegate

#define YUserDefaults?????? [NSUserDefaults standardUserDefaults]

#define YNotificationCenter [NSNotificationCenter defaultCenter]

// 通知

// 注冊(cè)通知

#define NOTIFY_ADD(_noParamsFunc, _notifyName)? [[NSNotificationCenter defaultCenter] \

addObserver:self \

selector:@selector(_noParamsFunc) \

name:_notifyName \

object:nil];

// 發(fā)送通知

#define NOTIFY_POST(_notifyName)? [[NSNotificationCenter defaultCenter] postNotificationName:_notifyName object:nil];

// 移除通知

#define NOTIFY_REMOVE(_notifyName) [[NSNotificationCenter defaultCenter] removeObserver:self name:_notifyName object:nil];

#define YImageNamed(s)? [UIImage imageNamed:s]


//APP版本號(hào)

#define YAppVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]

//系統(tǒng)版本號(hào)

#define YSystemVersion [[UIDevice currentDevice] systemVersion]

//獲取沙盒Document路徑

#define YDocumentPath [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]

//獲取沙盒temp路徑

#define YTempPath NSTemporaryDirectory()

//獲取沙盒Cache路徑

#define YCachePath [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]

//判斷是真機(jī)還是模擬器

#if TARGET_OS_IPHONE

//真機(jī)

#endif

#if TARGET_IPHONE_SIMULATOR

//模擬器

#endif

//開發(fā)的時(shí)候打印,但是發(fā)布的時(shí)候不打印的NSLog

#ifdef DEBUG

#define NSLog(...) NSLog(@"%s 第%d行 \n %@\n\n",__func__,__LINE__,[NSString stringWithFormat:__VA_ARGS__])

#else

#define NSLog(...)

#endif

//顏色

#define YRGBColor(r, g, b)???? [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]

//由角度轉(zhuǎn)換弧度

#define kDegreesToRadian(x)??????(M_PI * (x) / 180.0)

//由弧度轉(zhuǎn)換角度

#define kRadianToDegrees(radian) (radian * 180.0) / (M_PI)

//獲取一段時(shí)間間隔

#define kStartTime CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();

#define kEndTime?? NSLog(@"Time: %f", CFAbsoluteTimeGetCurrent() - start)

// 導(dǎo)航

#define PUSH(VC) [self.navigationController pushViewController:VC animated:YES];

#define POPVC [self.navigationController popViewControllerAnimated:YES];

#define POPTOROOT [self.navigationController popToRootViewControllerAnimated:YES];

持續(xù)更新小結(jié)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容