Terms Flashcards
What is a runtime instance of a class?
An object
An object contains what of the instance variables declared by its class and what to the methods of the class?
In-memory copy and pointers
What is the procedure to create an object?
Allocation and initialization
What two distinct pieces specify a class?
The interface and the implementation
Where does the class declaration and definitions for the public interface go?
The interface
Which file extension has the class, type, function and constant declarations in them?
The header files (.h)
Which file extension has the implementation in them and may contain Objective-C and C code in them?
The implementation files (.m)
Which file extension has the implementation in them and may contain Objective-C, C, and C++ code in them?
The implementation files (.mm)
What compiler directive insures that that the same file is never included more than once?
import
What file in a framework is best to import, and what is usually that filed named?
The framework's umbrella file and is usually the same name as framework; e.g., the syntax for importing the header files of the (hypothetical) Gizmo framework is: #import
A class declaration begins and ends with what compiler directives?
@interface and @end
What is the class name and what is the parent class name in the following syntax: @interface ClassA : ClassB @end
ClassA is the class name and ClassB is the parent class
True or False. An Objective-C class can have more than one parent.
False. In Objective-C, a class can have only one parent.
What are the only two types of declarations that can be in a class declaration?
Property and method declarations
Where do any class declarations of custom functions, constants, or data types go in the interface file (.h)?
Outside of the @interface…@end block.
A class implementation begins and ends with what compiler directives?
@implementation and @end
What should an implementation file always import as part of its first lines of code?
It’s interface file.
What are the two types of variables that will contain an object that are supported in Objective-C and how are they declared?
Static variable declarations include the class name. Dynamic variable declarations use the type 'id' for the object.
What must go in front of all statically typed object variables and what does it represent?
An asterisk, which represents a pointer declaration.
True or False. An ‘id’ object variable type implies a pointer.
True.
What do you send to an object to call a method of that object?
A message
What is another way to say that you are sending a message to an object?
Messaging
What are the two types of methods in Objective-C?
Instance and class methods
Which type of method is a method whose execution is scoped to a particular instance of the class?
Instance method
Which type of method is a method whose execution is scoped to a method’s class?
Class method
True or False. You can call an instance method before you create an instance of the class.
False. You must first create an instance of the class and then message that instance method through that instance.
True or False. A class method does not require an instance of an object to be the receiver of a message.
True.
Fill in the missing component of a method declaration.
The declaration of a method consists of the method type identifier, a return type, one or more what, and the parameter type and name information.
Signature keywords
The minus sign (-) precedes what type of method?
Instance method
The plus sign (+) precedes what type of method?
Class method
What is a method’s actual name?
A concatenation of all the signature keywords, including colon characters.
What does the colon characters in a method declaration declare the presence of?
A parameter
True or False. If a method has no parameters, you still put a colon character after the first and only method signature keyword.
False. You omit the colon character for no parameters.
Although the phrase “sending a message” is commonly used as a synonym for “calling a method,” what does the actual sending?
The Objective-C runtime.
What is required of the runtime to dispatch a message?
A message expression
What is used in a message expression to enclose the message?
Square brackets ([ and ])
What does the first keyword just inside the leftmost bracket in message expression designate?
The object receiving the message or to whom the message is being sent to
What does nesting message expressions help avoid?
Declaring numerous local variables to store the results from each of the message expressions
What is notation syntax is used for invoking accessor methods?
Dot-notation.
What do accessor methods get and set of an object?
Their state
What is key to the an object’s encapsulation?
Their accessor methods
What do accessor methods provide to all instances for accessing that state?
A common interface
True or False. You cannot use a reference to a dynamically typed object (type of id) in a dot-notation expression.
True.
What is required to message a class itself?
A class method
What type of object is a class created by the runtime?
Type Class
A factory method creates a new instance of the class or is used for accessing some piece of shared information associated with the class. What type of methods are these often used factory methods?
Class methods
A property the the general sense is some data what or what by and object?
Encapsulated or stored
A property is either an attribute—such as a name or a color—or a what to one or more other objects?
Relationship
Accessor methods provide the what and what actions that enable users of an object access to the encapsulated properties?
Get and set
True or False. A “getter” accessor method, which returns the value of a property, has the same name as the property.
True.
True or False. A “setter” accessor method, which sets a new value for a property, has the same name as the property.
False. A “setter” accessor method has the form setPropertyName:, where the first letter of the property name is capitalized.
What does the acronym KVC stand for and what does it do?
Key-value coding, which is a mechanism for accessing an object’s properties indirectly through their names.