Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default Implementation of Objective-C Protocol

The method discussion for setValue:forKeyPath: in Apple's NSKeyValueCoding Protocol documentation starts with:

The default implementation of this method [...]

Now, this might just be me getting caught with semantics but:

  1. How can an Objective-C Protocol have a default implementation?
  2. Since NSObject doesn't appear to conform to this protocol, how would one be able to take advantage of this default implementation in their own NSObject subclasses?

1 Answers

NSKeyValueCoding is an informal protocol, which means it's implemented as a category (in this case, on NSObject). The NSObject class provides the default implementation of the methods declared in the category.

like image 172
jlehr Avatar answered Feb 04 '26 13:02

jlehr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!