ios 開發中常用的宏定義 --歡迎補充

來源:互聯網
上載者:User

標籤:

////  CommonMacroDefinition.h//  LearnThread////  Created by Marico Sun in Beijing on 16/7/4.//  Copyright © 2016年 QL. All rights reserved.////判斷是否要Log 可以列印檔案名 函數名 行數#ifdef NEED_DEBUG#define NSLog(format, ...) //Log定義...#else#define NSLog(format, ...) do { NSLog(@"<%@ : %d : %s>-: %@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, __FUNCTION__, [NSString stringWithFormat:format, ##__VA_ARGS__]); } while(0)#endif/// debug 模式 和release 模式下的列印#ifdef DEBUG#define LOG(...) NSLog(__VA_ARGS__)#else#define LOG(...)#endif/// blcok 和self 引起的循環參考警告??的處理問題#define WEEK_REF(obj) __weak typeof(obj) __##obj = obj/// 本機資料的存取#define USERDEFAULTS (NSUserDefaults *)[NSUserDefaults standardUserDefaults]/// 儲存常量資訊到本地#define USERDEFAULTS_V_K(v,k) [USERDEFAULTS setObject:v forKey:k]/// 擷取本地儲存的常量資訊From V(v is key)#define USERDEFAULTS_K(k) [USERDEFAULTS objectForKey:k]/// 擷取版本號碼#define OSVERSION [[[UIDevice currentDevice] systemVersion] floatValue]/// 擷取View的屬性#define GetViewWidth(view)  view.frame.size.width#define GetViewHeight(view) view.frame.size.height#define GetViewX(view)      view.frame.origin.x#define GetViewY(view)      view.frame.origin.y/// 螢幕常量#define GetScreenWidth      [[UIScreen mainScreen] bounds].size.width#define GetScreenHeight     [[UIScreen mainScreen] bounds].size.height/// 擷取圖片資源#define GetImage(imageName) [UIImage imageNamed:[NSString stringWithFormat:@"%@",imageName]]/// rgb顏色設定#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]/// UUID#define UUID [[[UIDevice currentDevice] identifierForVendor] UUIDString]/// 擷取當前語言#define CurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])

/// 歡迎補充

ios 開發中常用的宏定義 --歡迎補充

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.