What? Classes like NSDateFormatter, NSCalendar are heavy to instantiate.
How? Create singleton (and it should be thread-safe if the singleton is created properly.)
Tips: If possible, use UNIX epoch (an Int) to represent a date. That speeds up the date object creation (vs. creation by parsing date formatted string.)
Author: Weiran
bounds vs. frame
- bounds: uses its own coordinate system, used to place views in itself.
- frame: uses parent view’s coordinate system, used to place it in the parent view.
Persistent local storage options
- NSUserDefaults – a tiny piece of info
- JSON files, NSCoding – large one time data, when used, need to first load from disk to memory. And entire payload has to be loaded before being used.
- SQLite, Core Data – large queryable data
When to use weak variable
Object A holds a reference to Object B while Object B also holds a reference to Object A, then we have a retain cycle here. To break it, one of the objects should be defined as weak. So the ARC can eventually count down to zero then release both objects.
UIScrollView performance
Load the subviews in the scroll view only when they need to be displayed. Similar to how UITableView works.
Background: colorWithPatternImage vs. UIImageView
For small image repeated/tiled, use colorWithPatternImage
For large full-size image, use UIImageView
Higher order functions
What? Functions you can pass as arguments to other functions. Such as map, filter, reduce, flatMap.
- map – operate on each element in the collection (then return a new collection).
- filter – return a subset of the collection that satisfies some condition.
- reduce – combine and return a single value.
- flatMap – flatten a collection of collections into a collection.
What slows down table scroll
- cell creation
- transparency
- gradient
- shadow
- off-screen drawing
- image scaling
- row height calculation
- api call
- data transformation
- deep subviews
lazy var
What? The vars that are marked lazy won’t be initialized until it’s used the first time.
When to use, if the var is a view?
- When the view has a good chance of never needed based on the condition. e.g., views in a collapsible panel.
- When the view isn’t needed before user interaction starts. Such as off-screen views, or views can be shown with delay.
35岁,记录一下。
一眨眼就两个儿子,很充实,老大很粘我,有点过分粘,老二很省心,有点过分省心,呵呵。理应觉得很累,但似乎还可以,应付得来,有赖老婆老人家们和各路亲朋好友的通力合作无私奉献。或许还有余力拼拼老三。
事业上有一个契机,但还是家庭为重,现在不是时候,自己也放心不下,对孩子们,对自己,对家人。机会总是有,各种不同的机会而已,要背水一战的机会,未必就是最好的。
另外从三月就开始搞一个项目,用的是工余时间,进度缓慢,意料之中,但缓慢的程度,还是意料之外。接下来需要更多的投入。人渐渐成熟,理想空想梦想幻想分得清点,看得透点。可以坚持的不妨多坚持,总是要一步一个脚印。
公司被Pearson收购之后,变得无奈。以前再黑暗的日子,总明白只要多撑一阵子,老板迟早给撤,换血之后就是一片明媚。事实也证明如此。但现在拥有懂技术的老板,超有能力的管理层,本应再无所求,然而却套在一个老旧母公司的框架下,动惮不得。Pearson也在重组中,但与其等待大象跳舞,不如及早散场。离开只是时间问题。
身体没有明显变化,运动少了,但带孩子也是体力活,人明显的耐操了。
上下班三个小时的车程加上喂奶哄睡等时间,这几年听了不少有声书籍,也是一种不错的充电方法,特适合现阶段。老婆送的新旧Kindle,实在没时间,没机会,拿起没几分钟就打瞌睡了。
技术还是不断充实,公司走agile还算中规中矩,所以开会比以前少,练手的机会比以前多,至少没有被发展所淘汰,也不算追的辛苦,毕竟这年头,再也没有人敢说自己是通才。
理财方面还行,这几年买股票都是走长线,基本就是买啥啥涨,例如AMZN, TSLA, 连MSFT也涨。当然超长线用来对冲的黄金也跌不少。自己所在的PSO,连自己都不确定明年的涨跌。所以,所谓的买啥啥涨,也是可以理解为简单的好运。
在KDP出的两本书,算是增加一丁点被动收入。其实写书的感觉不错,以后还会继续写。于人于己都有好处。在这个赶赶赶的时代,用心写写书,是一种很高质量的沉淀。
人很奇怪,过来三十就总是记不清自己是三十几?现在过三十五,估计又要糊涂几年,直到四十。