摘要: iOS中有4个触摸事件、6个手势识别、响应者链条1、4个触摸事件- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event; 2、. 阅读全文
posted @ 2014-03-05 23:46 郭晓 阅读(348) 评论(0) 推荐(0) 编辑
摘要: 由于OC是运行时语言,只有在程序运行时,才会去确定对象的类型,并调用类与对象相应的方法。利用runtime机制让我们可以在程序运行时动态修改类、对象中的所有属性、方法。下面就介绍运行时一种很简单的使用方式,将字典对象转为模型。当然,你可能会问,我用KVO直接调用 setValuesForKeysWithDictionary:方法,传入一个字典一样可以快速将字典转模型啊,但是这种方法有它的弊端,只有遍历某个模型中所有的成员变量,然后通过成员变量从字典中取出对应的值并赋值最为稳妥,否则,当模型中的属性数量与字典中的key的数量不一样时,就会报错。而且,由于runtime是更底层的语言,我们编写的. 阅读全文
posted @ 2014-03-05 21:43 郭晓 阅读(2118) 评论(2) 推荐(3) 编辑
摘要: 最近一直在研究runtime运行时机制的问题,我想可能也有很多人不太清楚这个问题吧?在这里跟大家沟通分享下我对与runtime机制的理解。 要理解runtime,首先我们要了解类和对象的内部结构,下面将首先介绍下OC中类与对象的结构层次。 一、首先,从runtime.h头文件中找到对 class 与 object 的定义/// An opaque type that represents an Objective-C class.typedef struct objc_class *Class;/// Represents an instance of a class.struct objc. 阅读全文
posted @ 2014-03-05 21:02 郭晓 阅读(2740) 评论(1) 推荐(4) 编辑