Fork me on GitHub

2012年5月10日

摘要: http://southking.iteye.com/blog/1489462假设两个ViewController之间已经建立了SegueA:TableViewController的子类 B:viewController A --> B 传送数据类Player的对象player1.设置Segue的identifier2.在B.h里添加Java代码@property(nonatomic,strong)Player*player; 在B.m里添加Java代码@synthesizeplayer;3.在A.m里重写UIViewController 的以下方法Java代码-(void)prepar 阅读全文
posted @ 2012-05-10 19:22 pengyingh 阅读(569) 评论(0) 推荐(0)
摘要: http://southking.iteye.com/blog/1487806ARC是什么ARC是iOS 5推出的新功能,全称叫 ARC(Automatic Reference Counting)。简单地说,就是代码中自动加入了retain/release,原先需要手动添加的用来处理内存管理的引用计数的代码可以自动地由编译器完成了。该机能在 iOS 5/ Mac OS X 10.7 开始导入,利用 Xcode4.2 可以使用该机能。简单地理解ARC,就是通过指定的语法,让编译器(LLVM 3.0)在编译代码时,自动生成实例的引用计数管理部分代码。有一点,ARC并不是GC,它只是一种代码静态分析 阅读全文
posted @ 2012-05-10 19:17 pengyingh 阅读(1296) 评论(0) 推荐(0)
摘要: 前两节我们对 ARC(Automatic Reference Counting) 有了一个基本的理解,但是 ARC 是怎么产生的,为什么苹果要在其最新的 iOS/Mac OS X 上导入该框架? 如果不理解其背后的基本原理,只是死记硬背那些规则/方法,是毫无意义的。就像我们从小接受的填鸭式教育,基本上到后来都还给老师了。本节,我们先来看看 ARC 产生之前的 Objective-C 内存管理世界,然后再来看看导入 ARC 后,新的 LLVM 编译器在背后为我们做了什么。Objective-C 内存管理和许多面向对象语言一样,Objective-C 中内存管理的方式其实就是指引用计数(Refer 阅读全文
posted @ 2012-05-10 18:56 pengyingh 阅读(212) 评论(0) 推荐(0)
摘要: NSArray *allObject = [dictionary allValues];[allObject makeObjectsPerformSelector:@selector(objSel)]; 阅读全文
posted @ 2012-05-10 18:06 pengyingh 阅读(162) 评论(0) 推荐(0)
摘要: Stream是单向的,Reading From Input Streams:1.Create and initilize an instance of NSInputStream from s source of data;2.Sechedule the stream object on a run loop and open the stream;3.Handle the events that the stream object reports to its delegate;4.When there is no data to read,dispose the stream object 阅读全文
posted @ 2012-05-10 17:57 pengyingh 阅读(180) 评论(0) 推荐(0)
摘要: http://www.cnblogs.com/wustlj/archive/2011/12/20/2294745.html所有的引用计数系统,都存在循环应用的问题。例如下面的引用关系:对象a创建并引用到了对象b.对象b创建并引用到了对象c.对象c创建并引用到了对象b.这时候b和c的引用计数分别是2和1。当a不再使用b,调用release释放对b的所有权,因为c还引用了b,所以b的引用计数为1,b不会被释放。b不释放,c的引用计数就是1,c也不会被释放。从此,b和c永远留在内存中。这种情况,必须打断循环引用,通过其他规则来维护引用关系。比如,我们常见的delegate往往是assign方式的属性 阅读全文
posted @ 2012-05-10 17:37 pengyingh 阅读(2983) 评论(0) 推荐(0)
摘要: http://southking.iteye.com/blog/1487811概念当我们使用强参照(Strong reference)时,往往需要留意循环参照的问题。循环参照指的是两个对象被互相强参照,以至于任一对象都不能释放。一般情况下,当对象之间有“父子关系”时,强参照的情况发生的比较多。比如通讯薄对象AddrBook和每个通讯录Entry的关系如下。这种情况下,由于Entry对象被AddrBook强参照,所以不能释放。另一方面,如果Entry被释放了,AddrBook对象的强参照也就没有了,其对象也应被释放。解决方式像上面的例子,当多个对象间有“父子关系”时,需要在一侧用“弱参照”来解决 阅读全文
posted @ 2012-05-10 17:22 pengyingh 阅读(316) 评论(0) 推荐(0)
摘要: http://southking.iteye.com/blog/1487814自 Xcode4.2 开始导入ARC机制后,为了支持对象间的转型,Apple又增加了许多转型用的关键字。这一讲我们就来了解其用法,以及产生的理由。引子我们先来看一下ARC无效的时候,我们写id类型转void*类型的写法:12id obj = [[NSObject alloc] init];void *p = obj;反过来,当把void*对象变回id类型时,只是简单地如下来写,12id obj = p;[obj release];但是上面的代码在ARC有效时,就有了下面的错误: error: implicit ... 阅读全文
posted @ 2012-05-10 16:30 pengyingh 阅读(183) 评论(0) 推荐(0)
摘要: Both detachNewThreadSelector and performSelectorInBackground are used to call a method in the background.Is there any difference between the 2 methods? or do they both work the same way?answer:They're both essentially the same but slightly different paradigms. Behind the scenes they do exactly t 阅读全文
posted @ 2012-05-10 16:10 pengyingh 阅读(562) 评论(0) 推荐(0)
摘要: http://blog.sina.com.cn/s/blog_9030ba4b01012db1.html简介:CAEmitterLayer提供了一个基于Core Animation的粒子发射系统,粒子用CAEmitterCell来初始化。粒子画在背景层盒边界上Properties:birthRate:粒子产生系数,默认1.0;emitterCells:装着CAEmitterCell对象的数组,被用于把粒子投放到layer上;emitterDepth:决定粒子形状的深度联系:emitter shapeemitterMode:发射模式NSString * const kCAEmitterLayer 阅读全文
posted @ 2012-05-10 16:08 pengyingh 阅读(328) 评论(0) 推荐(0)
摘要: http://www.x2x1.com/show/9787537.aspxHow can I calculate points around a sphere? I need this for my particles explosion. I don't want the particle's points to be all random. I need them in a spherical pattern. For 2d circle explosion I was using this:float n=many;float rad = 1;for (int i = 0 阅读全文
posted @ 2012-05-10 15:56 pengyingh 阅读(220) 评论(0) 推荐(0)
摘要: uiview类每次nib加载的时候,更新此方法,区别,viewDidLoad方法只执行一次,此方法每次切换到视图都会加载,类似uiviewController的 - (void)viewWillAppear:(BOOL)animated; 方法- (void)awakeFromNib当IB加载的时候, 界面的补充初始化用这个. 阅读全文
posted @ 2012-05-10 12:20 pengyingh 阅读(350) 评论(0) 推荐(0)
摘要: 1.TARGETS --->build settings 搜索 compiler 找到 compiler for c/c++/objective-c 改成 APPLE LLVM compiler 3.02.TARGETS --->build settings 搜索 analyzer Run Static Analyzer 改成 YES3.TARGETS --->build settings 搜索 automatic objective-c Automatic Reference Counting 改成YES4.From Xcode's m... 阅读全文
posted @ 2012-05-10 09:32 pengyingh 阅读(379) 评论(0) 推荐(0)

导航