iOS开发小记(十三)

1、软编码和硬编码如何区分

       软编码:使用CPU进行编码
       硬编码:使用非CPU进行编码,如显卡GPU、专用的DSP、FPGA、ASIC芯片等
 

 2、连续的动画

NSOperationQueue 串行UIview和CAlayer 的动画
 

3、UIImageView

UIImageView setAnimationImages 和 startAnimating 搭配使用
 

4、类加载函数

+(void)initialize
Thus the method may never be invoked if the class is not used
 The runtime sends the initialize message to classes in a thread-safe manner. Superclasses receive this message before their subclasses.
 
+(void)load
In addition:
 
A class’s +load method is called after all of its superclasses’ +load methods.
A category +load method is called after the class’s own +load method.
 
Apple的文档很清楚地说明了initialize和load的区别在于:load是只要类所在文件被引用就会被调用,而initialize是在类或者其子类的第一个方法被调用前调用。所以如果类没有被引用进项目,就不会有load调用;但即使类文件被引用进来,但是没有使用,那么initialize也不会被调用。
 
 

5、AnimationViewManager的设计

Protocal
1、view调用manager,传递动画类型和显示view。
2、manager新建特定的动画类型,添加到view。
3、manager调用通用的动画开始接口。
4、view调用manager,动画尚未结束,进入队列。
5、动画播放结束,回调manager,manager重新开始动画。
 
 
animation.delegate 会有strong的引用
如果animation.delegate = self,那么会有retain cycle
self.view.layer removeAnimationForKey:@THE_ANIMATION_KEY]
 

layer Animation在进入后台的时候回调用
animationDidStop
 

 6、异常处理

    //注册异常处理
    NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
 
 

7、Textkit

NSTextAttachment
其实只是使用 NSTextAttachment 将想要插入的图片作为一个字符处理,转换成 NSAttributedString ,然后 UITextView 直接进行渲染就搞定了。上面的代码是初始化一个 NSTextAttachment ,然后 set 一下 image 属性,也可以使用 NSTextAttachment 的 init(data contentData: NSData?, ofType uti: String?) 方法来设置图片。 

8、layer的位置 

position 用来设置CALayer在父层中的位置 
anchorPoint 决定着CALayer身上的哪个点会在position属性所指的位置
 

 9、解析url的query字符串

 ```
        NSURLComponents *urlComponents = [NSURLComponents componentsWithURL:[request URL]
                                                    resolvingAgainstBaseURL:NO];
        NSArray *queryItems = urlComponents.queryItems;
        NSString *type = [self valueForKey:@"type"
                              fromQueryItems:queryItems];
 ```
 
 

10、持久化

一个对象对应一张表,对象名PeristablePerson对应表名persistable_person,属性名lastName对应字段名last_name,即在大写字母前加"_"并将大写字母替换为小写。没有大写字母则不变。
 
属性名不能加"_",如last_name,否则查询时属性值为nil,即便数据库中不为null。 
1,% :表示任意0个或多个字符。可匹配任意类型和长度的字符,有些情况下若是中文,请使用两个百分号(%%)表示。
2,_ : 表示任意单个字符。匹配单个任意字符,它常用来限制表达式的字符长度语句:
3,[ ] :表示括号内所列字符中的一个(类似正则表达式)。指定一个字符、字符串或范围,要求所匹配对象为它们中的任一个。
4,[^ ] :表示不在括号所列之内的单个字符。其取值和 [] 相同,但它要求所匹配对象为指定字符以外的任一个字符。
5,查询内容包含通配符时
由于通配符的缘故,导致我们查询特殊字符“%”、“_”、“[”的语句无法正常实现,而把特殊字符用“[ ]”括起便可正常查询。 
 
 
 

 

11、statusBar通知
CWStatusBarNotification
 
 
 
 
 
原文地址:https://www.cnblogs.com/loying/p/5586465.html