What was wrong with the NSEnumerator technique and why NSFastEnumeration was introduced?
What was wrong with the NSEnumerator technique and why NSFastEnumeration was introduced?
The main issues with NSEnumerator were:
Performance overhead: Using NSEnumerator involves creating an object to represent the enumeration and calling a method on it for every single iteration. This incurs message send overhead for each iteration, which can be inefficient, especially for large collections.
Lack of language support: NSEnumerator uses a separate object and method calls to perform enumeration, which is not as tightly integrated with the language syntax compared to modern enumeration techniques.
To address these shortcomings, Apple introduced NSFastEnumeration in OS X Leopard and iOS 2.0. NSFastEnumeration provides a more efficient and convenient way to enumerate collections:
Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.