iOS 小知识-tips

时间:2014-04-28 15:19:16   收藏:0   阅读:579

--->1<---

arc的项目中使用非arc代码,则添加-fno-objc-arc;

非arc项目中使用arc代码,则添加-fobjc-arc。

 

--->2<---

实用的类

NSKeyedArchiver

[UIScreen mainScreen]

[UIDevice currentDevice]

[UIFont familyNames]

[UIApplication sharedApplication]

[NSUserDefaults standardUserDefaults]

[NSNotificationCenter defaultCenter]

[NSBundle mainBundle]

[NSLocale preferredLanguages]

便利的宏

#define rgba(r,g,b,a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)]

 

//程序沙盒 NSHomeDirectory()

#define LLC_SandBox_Document NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0]

#define LLC_SandBox_Library NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES)[0]

#define LLC_SandBox_Temp NSTemporaryDirectory()

 

/** DEBUG LOG **/

#ifdef DEBUG

#define DLog( s, ... ) NSLog( @"< %@(%d)(%s) >\n%@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent],__LINE__,__PRETTY_FUNCTION__ , [NSString stringWithFormat:(s), ##__VA_ARGS__] )

#else

#define DLog( s, ... )

#endif

 

#define BACK(block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block)

#define MAIN(block) dispatch_async(dispatch_get_main_queue(),block)

#define IMGBGLS(tpImg) (tpImg) = [(tpImg) stretchableImageWithLeftCapWidth:floorf((tpImg).size.width/2) topCapHeight:floorf((tpImg).size.height/2)]  //从1/2的宽,1/2的高方向,拉伸图片

#define FilterHtmlText(x) (x)=[[(x) componentsSeparatedByCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"[]{}<p><br/></p>#%-*+=_\\|~(<>$%^&*)_+ "]]componentsJoinedByString: @""]

 

--->3<---

 

iOS 小知识-tips,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!