Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

Performance Considerations

Though key-value coding is efficient, it adds a level of indirection that is slightly slower than direct method invocations. You should use key-value coding only when you can benefit from the flexibility that it provides.

Additional optimization opportunities may be added in the future, but these will not change basic methods for key-value coding compliance.

Contents:

Overriding Key-Value Coding Methods
Optimizing To-Many Relationships


Overriding Key-Value Coding Methods

The default implementations of the key-value coding methods, such as valueForKey:, cache Objective-C runtime information to increase efficiency. You should take care when overriding these implementations to ensure that you do not adversely affect application performance.

Optimizing To-Many Relationships

To-many relationships that are implemented using the indexed form of the accessors -countOf<Key> and -objectIn<Key>AtIndex: may benefit from implementing the optional -get<Key>:range: method. This method should return an array containing the objects in the specified range.

Similarly, if the to-many relationship contents are mutable, you can implement -replaceObjectIn<Key>AtIndex:withObject:. The implementation of this method replaces the object at the specified index with the new object.



< Previous PageNext Page > Hide TOC


Last updated: 2007-06-06




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice