Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Cocoa (API)
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Late binding== In most object-oriented languages, calls to methods are represented physically by a pointer to the code in memory. This restricts the design of an application since specific ''command handling'' classes are needed, usually organized according to the [[chain-of-responsibility pattern]]. While Cocoa retains this approach for the most part, Objective-C's [[Name binding#Late static|late binding]] opens up more flexibility. Under Objective-C, methods are represented by a ''selector'', a string describing the method to call. When a message is sent, the selector is sent into the Objective-C runtime, matched against a list of available methods, and the method's ''implementation'' is called. Since the selector is text data, this lets it be saved to a file, transmitted over a network or between processes, or manipulated in other ways. The implementation of the method is looked up at runtime, not compile time. There is a small performance penalty for this,<ref>[[Wikibooks:Programming Mac OS X with Cocoa for beginners/Objective C, the language and its advantages#Some Objective-C advantages|Wikibooks - Some Objective-C advantages]]</ref> but late binding allows the same selector to reference different implementations. By a similar token, Cocoa provides a pervasive data manipulation method called ''key-value coding'' (KVC).<ref>{{Cite web |url=https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/KeyValueCoding/ |title=Key-Value Coding Programming Guide |access-date=September 27, 2021}}</ref> This allows a piece of data or property of an object to be looked up or changed at runtime by name. The property name acts as a key to the value. In traditional languages, this late binding is impossible. KVC leads to great design flexibility. An object's type need not be known, yet any property of that object can be discovered using KVC. Also, by extending this system using something Cocoa terms ''key-value observing'' (KVO), automatic support for [[undo|undo-redo]] is provided. Late static binding is a variant of binding somewhere between static and dynamic binding. The binding of names before the program is run is called static (''early''); bindings performed as the program runs are dynamic (''late'' or ''virtual'').
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Cocoa (API)
(section)
Add topic