这是一个开源库,作者 Max Howell,此人也是 Homebrew 的作者,这里有段故事,据说当年 Max 参加 Google 的面试,因不(拒)会(绝)写反转二叉树而没有拿到 offer,江湖中也算得上一号人物。PromiseKit 这个库还是蛮大的,据说为了完成这个库前后总共花费了 Max 数千小时的工作量,嗯,数千小时,假设1天2小时,一年365天的话,1000小时也得差不多一年半的时间,嗯,牛。PromiseKit 传送门
Never put complex layout code or complex layout animation in viewDidLayoutSubviews(), layoutSubviews(), if you did, you’ll fall in kinds of weird crashes in some old os version devices. Good practice is put them into some refresh function such as refreshView() after networking data received or view model just updated.
If you still have to do something in those functions, don’t forget to call super implement.
Merge code will be harder when there were some foundation module refactorings in both branches.
For an simplest example, you do module A refactoring A for feature A in branch feature/A, but for some reason you can not merge them back to develop branch right now, and you do another module A refactoring B for feature B in branch feature/B, which should be merge back to develop right now. Now, when you need merge feature/A back to develop, it’s very likely that there will be a large number of conflicts need resolve and by the way it’s also very likely that you can not use git tools such like Cherry Pick any more. In this case you can only do manually merge code by code, which is painful and error prone.
So, the better way to avoid these things happen is to use separate commit or branch when doing refactoring, and in this way you can merge some module refactorings at an earlier time easily, and make life easy.:D
Another case is the remote image from backend, they keep only @3 version, and the client’s UI layout want use the origin size of the image, then we can just rescale it.
Calling CALayer.presentationLayer will trigger the method “initWithLayer” automatically, so, make sure you overwrite that init method and do some thing necessary.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
- (instancetype)initWithLayer:(id)layer {
self = [super initWithLayer: layer];
if (self == nil) {
returnnil;
}
MLog(@"[CMCircleLayer] --> initWithLayer");
/***************************
* Do some thing necessary
**************************/
returnself;
}
Another trick for free, set a fast speed to main window’s layer can ignore all animations on auto test.