|
In computing, type introspection is a capability of some object-oriented programming languages to determine the type of an object at runtime. This is a notable capability of the Objective C language. Originally, the word computing was synonymous with counting and calculating, and a science that deals with the original sense of computing mathematical calculations. ...
In computer science, object-oriented programming, OOP for short, is a computer programming paradigm. ...
Objective-C, often referred to as ObjC or more seldom as Objective C or Obj-C, is a reflective, object oriented programming language which adds Smalltalk-style messaging to C. Today it is used primarily on Mac OS X and GNUstep, two environments based on the OpenStep standard, and is...
In Objective C, for example, both the generic Object and NSObject (in Cocoa/OpenStep) provide the method isMemberOfClass: which returns true if the argument to the method is an instance of the specified class. The method isKindOfClass: analogously returns true if the argument inherits from the specified class. Objective-C, often referred to as ObjC or more seldom as Objective C or Obj-C, is a reflective, object oriented programming language which adds Smalltalk-style messaging to C. Today it is used primarily on Mac OS X and GNUstep, two environments based on the OpenStep standard, and is...
Cocoa is the dried and partially fermented fatty seed of the cacao tree from which chocolate is made. ...
OpenStep is an open object-oriented API specification for an object-oriented operating system that uses any modern operating system as its core, principally developed by NeXT. It is important to recognize that while OpenStep is an API specification, OPENSTEP (all capitalized) is a specific implementation of this OpenStep developed...
Used mainly in object-oriented programming, the term method refers to a piece of code that is exclusively associated either with a class (called class methods or static methods) or with an object (called instance methods). ...
For example, say we have a Puppy and Kitten class inheriting from Animal, and a Vet class. Now, in the desex method we can write - desex: (id) to_desex { if([to_desex isKindOfClass:[Animal class]]) { //we're actually desexing an Animal, so continue if([to_desex isMemberOfClass:[Puppy class]]) desex_dog(to_desex); else if([to_desex isMemberOfClass:[Kitten class]]) desex_cat(to_desex); else error(); } else { error(); } } Now, when desex is called with a generic object (an id), the function will behave correctly depending on the type of the generic object. Type introspection can be used to implement polymorphism. In computer science, polymorphism means allowing a single definition to be used with different types of data (specifically, different classes of objects). ...
See also |