摘要: 在编程过程中,我们经常会用到for循环,而且for循环要做很多相关的任务。比如:for (i = 0; i < count; i++) { //do a lot of work here. doSomething(i); }如果for循环中处理的任务是可并发的,显然放到一个线程中处理是很慢的,GCD提供两个函数dispatch_apply和dispatch_apply_f,dispatch_apply是用于Block的,而dispatch_apply_f可以用于c函数,它们可以替代可并发的for循环,来并行的运行而提高执行效率。dispatch_queue_t queue = di... 阅读全文
posted @ 2013-12-10 15:27 Story Of My Life 阅读(537) 评论(0) 推荐(0) 编辑
摘要: 可以在Building Phases中Compiling Sources中进行Compile Flag的设置:1、不用arc来编译文件 -fno-objc-arc2、强制取消一个文件的编译警告 -w 阅读全文
posted @ 2013-11-26 16:05 Story Of My Life 阅读(210) 评论(0) 推荐(0) 编辑
摘要: http://www.cnblogs.com/lixiaohui-ambition/archive/2012/08/21/2649052.html 阅读全文
posted @ 2013-11-19 19:15 Story Of My Life 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 利用颜色的RGB值,通过公式g = R*0.299 + G*0.587 + B*0.114求出g, g越小颜色越深 阅读全文
posted @ 2013-10-23 16:53 Story Of My Life 阅读(1380) 评论(0) 推荐(0) 编辑
摘要: console里可以很方便的查看任何view的层级:po [[self view] recursiveDescription] 阅读全文
posted @ 2013-08-08 19:19 Story Of My Life 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 需要在自定义类中实现NSCode的两个方法,同时的声明实现协议。- (id)initWithCoder:(NSCoder *)coder{ if (self = [super init]) { _name = [coder decodeObjectForKey:@"name"]; _signatureURL = [coder decodeObjectForKey:@"signatureURL"]; } return self;}-(void)encodeWithCoder:(NSCoder *)coder{ [coder encodeObje... 阅读全文
posted @ 2013-07-03 16:15 Story Of My Life 阅读(282) 评论(0) 推荐(0) 编辑
摘要: 根据文字内容长度动态调整label和cell的高度1、首先获得文字信息所需要的sizeCGSize titleSize = [question.titlesizeWithFont:[UIFontsystemFontOfSize:17] constrainedToSize:CGSizeMake(209, 1000) lineBreakMode:UILineBreakModeWordWrap];其中fontsize要和label.text.size保持一致,另外可以限制size的大小2、一定要将label的numberOfLine设为03、最后将label的height设为titleSize.he 阅读全文
posted @ 2013-06-08 00:38 Story Of My Life 阅读(2060) 评论(0) 推荐(0) 编辑
摘要: - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;{ NSLog(@"Did start loading: %@ auth:%d", [[request URL] absoluteString], _authenticated); if (!_authenticated) { _authenticated = NO; ... 阅读全文
posted @ 2013-05-17 13:22 Story Of My Life 阅读(1895) 评论(0) 推荐(0) 编辑
摘要: 在项目目录里git initgit add.git commit-m“Initial Commit” 阅读全文
posted @ 2013-05-14 12:54 Story Of My Life 阅读(131) 评论(0) 推荐(0) 编辑
摘要: - (void)setHighlighted:(BOOL)highlighted animated (BOOL)animated{ [super setHighlighted:highlighted animated:animated]; if(highlighted) { [(UIButton *)self.accessoryView setHighlighted:NO]; }}- (void)setSelected:(BOOL)selected animated:(BOOL)animated{ [super setSelected:selected a... 阅读全文
posted @ 2013-05-02 22:07 Story Of My Life 阅读(280) 评论(0) 推荐(0) 编辑