摘要: KVC,即NSKeyValueCoding,通过字符化名字作为Key来访问对象属性的机制。本质上,KVC在某种程度上提供了访问器的替代方案,只要是有可能KVC尽量使用访问器方法。以返回对象属性key例,KVC按如下顺序查找返回值:1、-()getKey访问器方法2、-()key3、调用valueFo... 阅读全文
posted @ 2014-07-10 17:55 simalone 阅读(436) 评论(0) 推荐(0) 编辑
摘要: Xib是 Interface Builder 3.0版本以后一种新的文件格式,相对Nib,它是一种扁平文件,更适合在版本控制中存储,差异化比较等。Xib相对Nib占用更大的空间,编译App后, Xib会编译进Nib。而编译后Nib会更小且不可编辑。 阅读全文
posted @ 2014-07-10 17:31 simalone 阅读(233) 评论(0) 推荐(0) 编辑
摘要: 1、instancetype只能用于方法的返回类型,而id用处和NSObject *类似。2、instancetype会告诉编译器当前的类型,这点和NSObject *类似,但id对于编译器却是无类型的,调用任何方法不会给出错误提示。3、对于init方法,id和instancetype是没有区别的。因为编译器会把id优化成instancetype。当明确返回的类型就是当前Class时,使用instancetype能避免id带来的编译不出的错误情况。4、NSObject Class和id都是仅包含了一个Class isa。但NSObject包含了更多方法的定义。5、id和instancetype 阅读全文
posted @ 2014-02-14 18:11 simalone 阅读(508) 评论(0) 推荐(0) 编辑
摘要: 链接:http://iosdevelopertips.com/objective-c/high-performance-collection-looping-objective-c.htmlNSArray:for (id object in array) :正向遍历最快;for (id object in [array reverseObjectEnumerator]) : 反向遍历;for (NSInteger i = 0; i < count; i++) : 当需要使用index或修改内容,先算出Count,再遍历最快;[array enumerateObjectsWithOptio 阅读全文
posted @ 2014-02-13 13:43 simalone 阅读(466) 评论(0) 推荐(0) 编辑
摘要: 官方文档:https://developer.apple.com/library/ios/documentation/General/Conceptual/DevPedia-CocoaCore/ClassCluster.html继承类簇会存在的问题:http://www.cnblogs.com/pengyingh/articles/2359201.html类簇如何实现的:http://seanmurph.com/weblog/make-your-own-abstract-factory-class-cluster-in-objective-c/简单概括:类簇使用抽象类工厂设计模式,重载allo 阅读全文
posted @ 2014-02-13 11:51 simalone 阅读(470) 评论(0) 推荐(0) 编辑
摘要: 近期处理了一个挂断电话后,莫名手机开始播放音乐的Bug。 所以顺便在这总结一下,对于IOS的AudioSession中断的几种处理情况。一、通过C语言的init方法配置interruptionl回调。建议用这种方法,但有些细节需要注意,后续会谈到。AudioSessionInitialize ( NULL, // 1 NULL, // 2 interruptionListenerCallback, // 3 userData ... 阅读全文
posted @ 2013-08-22 20:33 simalone 阅读(4136) 评论(0) 推荐(0) 编辑
摘要: Block 最大的便利就是简化的回调过程,实现编程之美。使用Block要谨记别造成对象互相引用导致对象无法被释放。关于闭包:http://baike.baidu.com/view/648413.htm 闭包是可以包含自由(未绑定到特定对象)变量的代码块;这些变量不是在这个代码块内或者任何全局上下文中定义的,而是在定义代码块的环境中定义。“闭包” 一词来源于以下两者的结合:要执行的代码块(由于自由变量被包含在代码块中,这些自由变量以及它们引用的对象没有被释放)和为自由变量提供绑定的计算环境(作用域)。在 Scala、Scheme、Common Lisp、Smalltalk、Groovy、... 阅读全文
posted @ 2012-03-12 10:27 simalone 阅读(201) 评论(0) 推荐(0) 编辑
摘要: Table 1Preprocessor macros and for logging in C/C++/Objective-C.MacroFormat SpecifierDescription__func__%sCurrent function signature.__LINE__%dCurrent line number in the source code file.__FILE__%sFull path to the source code file.__PRETTY_FUNCTION__%sLike __func__, but includes verbose type informa 阅读全文
posted @ 2011-12-07 13:29 simalone 阅读(185) 评论(0) 推荐(0) 编辑
摘要: Provider Push notifications: Production environment:gateway.push.apple.com port 2195; Development environment: gateway.sandbox.push.apple.com port 2195 You must compose the notification payload An alert message to display to the user A number to badge the application icon with A sound to play You a. 阅读全文
posted @ 2011-04-26 10:08 simalone 阅读(397) 评论(1) 推荐(0) 编辑
摘要: 网络上搜索,不断更新中…1.断点处查看变量内容:po objc:输出[objc descripton];print (int)[objc retainCount]:输出[objc retainCount)。注:print [objc retainCount]不行。print (CGRect)[view frame]:输出view.frame。 注:print [view frame]或 print (CGRect)view.frame不行。2.修改UIAlertView背景:theAlert.layer.contents = (id)[UIImageObjc CGImage];3.减少图片在程 阅读全文
posted @ 2010-12-21 16:34 simalone 阅读(243) 评论(0) 推荐(0) 编辑