摘要: 如果方法是没有返回值的,需要强转一个返回类型为void的临时函数指针,void (*objc_msgSendTyped)(id self, SEL _cmd, id obj, id arg1) = (void *)objc_msgSend;objc_msgSendTyped(self, addedS... 阅读全文
posted @ 2014-12-25 15:38 翛尧 阅读(359) 评论(0) 推荐(0) 编辑
摘要: 原文:http://blog.sunnyxx.com/2014/08/02/objc-weird-code/[娱乐向]objc最短的方法声明先来个娱乐向的。方法声明时有一下几个trick:返回值的- (TYPE)如果不写括号,编译器默认认为是- (id)类型:12- init;- (id)init;... 阅读全文
posted @ 2014-12-17 15:22 翛尧 阅读(279) 评论(0) 推荐(0) 编辑
摘要: 原文地址:http://blog.sunnyxx.com/2014/09/15/objc-attribute-cleanup/编译器属性__attribute__用于向编译器描述特殊的标识、检查或优化,几个常用的用法看《mattt大神的文章》就好。今天发现一个名为cleanup的黑魔法属性,简单介绍... 阅读全文
posted @ 2014-12-16 17:11 翛尧 阅读(302) 评论(0) 推荐(0) 编辑
摘要: 判断一个对象是否实现了某方法,而非继承而来。#import - (BOOL)realRespondsToSelector:(SEL)selector{ BOOL result = NO; u_int count; Method *methods= class_copyMethodL... 阅读全文
posted @ 2014-12-05 12:19 翛尧 阅读(279) 评论(0) 推荐(0) 编辑
摘要: http://shaheengandhi.com/controlling-thread-exit/While most concurrency can be dealt with by using GCD dispatch queues, there are some things for which you will want to use a separateNSThread. For instance, concurrent network programming remains mostly in this area. You may consider using the popula 阅读全文
posted @ 2014-04-11 14:24 翛尧 阅读(1261) 评论(0) 推荐(0) 编辑
摘要: 参考:http://www.cnblogs.com/blair/p/3229580.html(参考该文章写成)double tail(double x){ return x - floor(x);}// 判断y年m月(1,2,..,12,下同)d日是Gregorian历还是Julian历//(opt=1,2,3分别表示标准日历,Gregorge历和Julian历),是则返回1,是Julian历则返回0,// 若是Gregorge历所删去的那10天则返回-1int ifGregorian(int y, int m, int d, int opt){ if (opt == 1) ... 阅读全文
posted @ 2014-03-11 12:47 翛尧 阅读(1328) 评论(0) 推荐(0) 编辑
摘要: 农历数据解析:1901 - 2100 农历数据:const int HHLunarCalendarInfo[] = { 0x04AE53,0x0A5748,0x5526BD,0x0D2650,0x0D9544,0x46AAB9,0x056A4D,0x09AD42,0x24AEB6,0x04AE4A,/*1901-1910*/ 0x6A4DBE,0x0A4D52,0x0D2546,0x5D52BA,0x0B544E,0x0D6A43,0x296D37,0x095B4B,0x749BC1,0x049754,/*1911-1920*/ 0x0A4B48,0x5B25BC,0x06A550... 阅读全文
posted @ 2014-03-11 12:32 翛尧 阅读(969) 评论(0) 推荐(0) 编辑
摘要: 干支纪年法的简便算法 传统的计算法,必须知道一个已知年,然后往前后推算,有一定的难度,下面我给大家介绍一种干支纪年法的简便算法,每个字都有对应的一个符号。如下表: 4 5 6 7 8 9 0 1 2 3 甲 乙 丙 丁 戊 己 庚 辛 壬 癸 4 5 6 7 8 9 10 11 0 1 2 3 子 丑 寅 卯 辰 巳 午 未 申 酉 戌 亥 4 5 6 7 8 9 10 11 0 1 2 3 鼠 牛 虎 兔 龙 蛇 马 羊 猴 鸡 狗 猪 年份的最后一个数字就对应天干的相应的字,然后用年份除以12所得的余数,用这个余数去找相对应的地支字和十二生肖字,于是天干地支字的组合便是干支纪年... 阅读全文
posted @ 2014-03-11 12:27 翛尧 阅读(1592) 评论(0) 推荐(0) 编辑
摘要: 唯一标识 : NSString*identifier=[[NSProcessInfoprocessInfo]globallyUniqueString];创建临时文件路径:NSString *fileName=[NSStringstringWithFormat:@"%@_%@", [[NSProcessInfoprocessInfo] globallyUniqueString], @"file.txt"];NSURL *fileURL=[NSURLfileURLWithPath:[NSTemporaryDirectory() stringByAppendi 阅读全文
posted @ 2014-03-11 12:09 翛尧 阅读(3644) 评论(0) 推荐(0) 编辑
摘要: NSOutputStream-保存网络资源到本地_filePath= [[NetworkManagersharedInstance]pathForTemporaryFileWithPrefix:@"Get"];_fileStream= [NSOutputStreamoutputStreamToFileAtPath:self.filePathappend:NO];[_fileStreamopen];2.进行网络请求,并返回网络的数据。通过输出流对象,将数据写入到指定的文件中。- (void)connection:(NSURLConnection*)connection did 阅读全文
posted @ 2014-03-05 11:01 翛尧 阅读(2182) 评论(0) 推荐(0) 编辑