3

What I have learned from Cheddar for iOS

 1 year ago
source link: https://fann.im/blog/2012/08/12/what-i-have-learned-from-cheddar-for-ios/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

What I have learned from Cheddar for iOS

Aug 12, 2012

  1. Code Style.
  2. DRY,整理适合自己的代码库(SSToolkit)。
  3. application:didFinishLaunchingWithOptions: 里尽量少操作,减少 launch 时间。只做界面展示工作,数据层用 dispatch_async 异步操作。
  4. 多用 [image stretchableImageWithLeftCapWidth:5 topCapHeight:0] 图片拉伸,减小 App size。效果上并没有缺失很多。很多效果都可以用代码实现,不一定非得贴图。
  5. 数据层封装不同的对象,方便各种调用。直接用 dict 传来传去不够清晰。
  6. Core Data 和 UIViewController 可以很好的结合,深度封装后的确很方便,参见 SSManagedViewController = UIViewController+SSManagedObject(NSManagedObject),SSDataKit。但这样感觉 ViewController 很沉重,也可能是因为我对 Core Data 不熟悉,以后有机会加深一下 CD 的学习使用。
  7. KVO 是个好东西。
  8. 定义一些内部 scheme 来做界面跳转,x-cheddar-tag.
  9. UIColor+CheddariOSAdditions.h-cheddarTextColor,定义整体风格配色,很方便使用。UIFont+CheddariOSAdditions.h 同理。
  10. cellHeightForText:dispatch_once_t 生成一个单例 label,然后 sizeThatFits: 计算。
  11. prepareForReuse 释放数据。
  12. CDKHTTPClient 学习 AFN 的好例子。单实例,用 block 封装接口。Block is better than delegate, simple, clear and powerful.

Was this page helpful?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK