Skip to content

Commit dd5e2aa

Browse files
committed
[doc] Reduce the length of the docs
1 parent 3ca4555 commit dd5e2aa

File tree

2 files changed

+18
-21
lines changed

2 files changed

+18
-21
lines changed

include/swift/ABI/Metadata.h

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,28 +1168,25 @@ struct TargetClassMetadata : public TargetAnyClassMetadata<Runtime> {
11681168
Description = description;
11691169
}
11701170

1171-
/// Is this class an artificial subclass, such as one dynamically
1172-
/// created for various dynamic purposes like KVO?
1173-
//
11741171
// [NOTE: Dynamic-subclass-KVO]
1175-
// To implement Key-Value Observing without any code that notifies the
1176-
// observer, the KVO infrastructure uses dynamic subclassing with Objective-C
1177-
// runtime. When a variable is observed, KVO creates a secret dynamic subclass
1178-
// of that class under the hood which are defined with a prefix of
1179-
// `NSKVONotifying_`.
11801172
//
1181-
// While the observed variables have the type of the dynamic subclass, they
1182-
// must appear like their non-observed counterparts for the front-end user. To
1183-
// achieve this, the dynamic subclass overrides `-class` method which returns
1184-
// the original class type, and internally refers to the subclass in the
1185-
// runtime.
1173+
// Using Objective-C runtime, KVO can modify object behavior without needing
1174+
// to modify the object's code. This is done by dynamically creating an
1175+
// artificial subclass of the the object's type.
1176+
//
1177+
// The isa pointer of the observed object is swapped out to point to
1178+
// the artificial subclass, which has the following properties:
1179+
// - Setters for observed keys are overridden to additionally post
1180+
// notifications.
1181+
// - The `-class` method is overridden to return the original class type
1182+
// instead of the artificial subclass type.
11861183
//
1187-
// In the created subclass, `-set` methods for observed variables are
1188-
// overridden, where the calls to the observer notifications are triggered.
1189-
// KVO only generates one dynamic subclass for each class which overrides all
1190-
// setter methods of variables being observed. That is, setters of variables
1191-
// that are not observed are also not overridden in the dynamic subclass for
1192-
// efficiency.
1184+
// For more details, see:
1185+
// https://www.mikeash.com/pyblog/friday-qa-2009-01-23.html
1186+
1187+
/// Is this class an artificial subclass, such as one dynamically
1188+
/// created for various dynamic purposes like KVO?
1189+
/// See [NOTE: Dynamic-subclass-KVO]
11931190
bool isArtificialSubclass() const {
11941191
assert(isTypeMetadata());
11951192
return Description == nullptr;

stdlib/public/runtime/SwiftObject.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static Class _swift_getObjCClassOfAllocated(const void *object) {
9292
/// Fetch the ObjC class object associated with the formal dynamic
9393
/// type of the given (possibly Objective-C) object. The formal
9494
/// dynamic type ignores dynamic subclasses such as those introduced
95-
/// by KVO. See [NOTE: Dynamic-subclass-KVO]
95+
/// by KVO.
9696
///
9797
/// The object pointer may be a tagged pointer, but cannot be null.
9898
const ClassMetadata *swift::swift_getObjCClassFromObject(HeapObject *object) {
@@ -122,7 +122,7 @@ static Class _swift_getObjCClassOfAllocated(const void *object) {
122122
/// Fetch the type metadata associated with the formal dynamic
123123
/// type of the given (possibly Objective-C) object. The formal
124124
/// dynamic type ignores dynamic subclasses such as those introduced
125-
/// by KVO. See [NOTE: Dynamic-subclass-KVO]
125+
/// by KVO.
126126
///
127127
/// The object pointer may be a tagged pointer, but cannot be null.
128128
const Metadata *swift::swift_getObjectType(HeapObject *object) {

0 commit comments

Comments
 (0)