Skip to content

Commit

Permalink
edit 46 and 50: why we should know the methods invoked order in kvo
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenYilong committed Apr 6, 2016
1 parent bc3e0b6 commit 6f07b96
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
NSLog(@"3");
}

+ (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key {
return NO;
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,10 @@ KVO支持实例变量
###50. 如何关闭默认的KVO的默认实现,并进入自定义的KVO实现?


请参考:[《如何自己动手实现 KVO》](http://tech.glowing.com/cn/implement-kvo/)
请参考:

1. [《如何自己动手实现 KVO》](http://tech.glowing.com/cn/implement-kvo/)
2. [**KVO for manually implemented properties**]( http://stackoverflow.com/a/10042641/3395008 )

###51. apple用什么方式实现对一个对象的KVO?

Expand Down Expand Up @@ -963,6 +966,12 @@ KVO 在实现中通过 ` isa 混写(isa-swizzling)` 把这个对象的 isa

不信你把 `didChangeValueForKey:` 注视掉,看下 `observeValueForKeyPath:ofObject:change:context:` 会不会执行。

了解到这一点很重要,正如 [46. 如何手动触发一个value的KVO](https://github.com/ChenYilong/iOSInterviewQuestions/blob/master/01《招聘一个靠谱的iOS》面试题参考答案/《招聘一个靠谱的iOS》面试题参考答案(下).md#46-如何手动触发一个value的kvo) 所说的:

“手动触发”的使用场景是什么?一般我们只在希望能控制“回调的调用时机”时才会这么做。

而“回调的调用时机”就是在你调用 `didChangeValueForKey:` 方法时。

###52. IBOutlet连出来的视图属性为什么可以被设置成weak?

参考链接:[ ***Should IBOutlets be strong or weak under ARC?*** ](http://stackoverflow.com/questions/7678469/should-iboutlets-be-strong-or-weak-under-arc)
Expand Down

0 comments on commit 6f07b96

Please sign in to comment.