iOS 面试题汇总(三)
1.Difference between categories and extensions?
A:There are three difference beween categories and extensions:
- The extension has no name;
- The implementation of the extension must be in the main @implementation block of the file;
- The extension can easy declare property that need backend instance variable.
Reference:Difference between Category and Class Extension?
2.What is advantage of category?
A:
- You can add method to existing class even to that class whose source is not available to you.
- You can extend functionality of a class without subclassing.
- You can split implementation in multiple files.
3.What are KVO and KVC?
A:
Key-value observing is a mechanism that enables an object to be notified directly when a property of another object changes.
Key-value coding is a mechanism for indirectly accessing an object’s attributes and relationships using string identifiers.
Reference:Cocoa Core Competencies
继续阅读