Skip to content

Commit 7574278

Browse files
committed
添加参考链接《Apple 官方文档:Manual Change Notification》【46. 如何手动触发一个value的KVO
1 parent c925fff commit 7574278

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

01《招聘一个靠谱的iOS》面试题参考答案/《招聘一个靠谱的iOS》面试题参考答案(下).md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,8 @@ observer中需要实现一下方法:
745745
```
746746
这是完全没有必要的代码,不要这么做,这样的话,KVO代码会被调用两次。KVO在调用存取方法之前总是调用 `willChangeValueForKey:` ,之后总是调用 `didChangeValueForkey:` 。怎么做到的呢?答案是通过 isa 混写(isa-swizzling)。下文《apple用什么方式实现对一个对象的KVO?》会有详述。
747747

748+
参考链接: [µ](https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/KeyValueObserving/Articles/KVOCompliance.html#//apple_ref/doc/uid/20002178-SW3)
749+
748750

749751
###47. 若一个类有实例变量 `NSString *_foo` ,调用setValue:forKey:时,可以以foo还是 `_foo` 作为key?
750752
都可以。

0 commit comments

Comments
 (0)