• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/82

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

82 Cards in this Set

  • Front
  • Back
What is the runtime system?
Objective C tries to defer as many decisions from compile time and link time to run time as possible. Whenever possible it tries to dynamically perform operations such as creating objects and determining what methods to invoke. Therefore the Objective C language needs not only the compiler but the runtime system to execute compiled code.
What is the "id" data type?
A pointer to an object data structure.
What keyword describes a null object?
nil
What does it mean for an object to be dynamically typed?
The runtime system can find the exact class the object belongs to just by asking the object.
What does an object's "isa" variable do?
It allows the object to perform introspection.
What is introspection?
To find out about oneself.
What is reference counting?
The programmer is responsible for determining the lifetime of objects.
What is garbage collection?
The programmer passes on the responsibility for determining the lifetime of objects to the "Garbage Collector"
How do you get an object to do something?
By sending it a "message."
Give the structure of a message expression.
[receiver message];
What does this mean:
[myRectangle display];
It tells the myRectangle object to perform its display method which causes the rectangle to display itself.
What is a "selector" in a message?
The method name in a message serves to "select" the method's implementation.
How do you denote a method "setX" taking in 1 argument.
foo:
How do you denote a method "setXY" taking in 2 arguments
setXY:: // bad way
setX:y: // good way
How do you pass an optional number of arguments to a method?
Extra arguments are separated by commas.

Example:
[receiver makeGroup:group, memberOne, memberTwo, memberThree];

group here is required.
memberOne, memberTwo, memberThree were optional.
What happens when you try to send a message to nil at runtime.
Nothing.
Define "polymorphism"
The ability for one object to appear as and be used like another object. For example B implements A. Where A is an abstract class.
What is "dynamic binding?"
The selection of a method's implementation at runtime. When a message is sent, the runtime messaging routine looks at the method named in the message. It locates the receiver's implementation of the method and "calls" the method and passes to it a pointer to the receiver's instance variables.
Convert to bracket syntax:
myInstance.value = 10;
[myInstance setValue:10]
Convert to dot syntax:
[myInstance setValue:10]
myInstance.value = 10;
Is code this valid?
id y;
x = y.z;
No because y is untyped and z is undeclared.
How is the performance using dot syntax vs using bracket syntax.
The same.
Define "class object."
The compiler creates just one accessible object for each class, it is called the class object. It knows how to build new objects belonging to the class.
Define "class instance."
The objects that the "class object" builds.
Explain "class definitions are additive."
Each new class you define is based on another class from which it inherits methods and instance variables.
In AS3 properties is to what in Objective C.
Instance Variables.
What is the typical root class in Objective C?
NSObject
What is a superclass?
The parent class.
What is a subclass?
A child class.
What is a abstract class? Is it possible to create an instance of an abstract class?
A class that groups methods and instance variables that can be used by a number of different subclasses into a common definition. Objective C does not prevent you from instantiating a abstract class.
What method checks whether a receiver is an instance of a particular class? Give an example of usage.
isMemberOfClass. It is a method defined by NSObject.

if ([anObject isMemberOfClass: someClass]) { ... }
What method checks whether a receiver is an instance or inherits from a particular class? Give an example of usage.
isKindOfClass. It is a method defined by NSObject.

If ([anObject isKindOfClass: someClass]) { ... }
How do you create and initialize an instance?
myRectangle = [[Rectangle alloc] init];
How do you make static variables?
static int *aInt;
How do you make a static method?
+ (int *)myMethod
{
return 1;
}
If you need to perform stuff in the init part of the class, what method do you do it in?
- (id)init
{
if (self = [super init])
{
...
}
}
What does the "init" method do?
Initializes the instance variables of the receiver and returns itself.
What keyword does property declaration begin with?
@property
How do you declare a property with attributes?
@property(attribute1, attribute2, etc...)
If we have a property "foo" with default getter and setters, what would the getter and setter names be?
getter: foo
setter: setFoo:
If we want to change the default getter and setter names when declaring a property, how do we do that?
@property(getter=gettername, setter=settername) type propertyname;
How do you declare a property that is read only?
@property (readonly) type propertyname;
What does it mean for a property to be atomic?
It means code from your app can call the properties getter/setters from multiple threads without fear of a crash or inconsistent value. This usually means that both the getter and setter are synchronized using a locking mechanism.
Explain this property attribute, "assign."
species the setter to use simple assignment. This is the default.
Explain the property attribute, "retain"
The previous value is sent a release message(dealloc).
Explain the property attribute, "copy"
The previous value is sent a release message(dealloc). A copy is made by invoking the copy method.
What does @dynamic and @synthesize do?
if a property is @dynamic (the default) you must provide the getter and setter yourself. If you @synthesize a property, the compiler will create them for you.
Write a getter and setter for
@property (copy, readwrite) NSString *value;
@dynamic value;

- (NSString *)value
{
return value;
}

- (void)setValue:(NSString *)newValue
{
if (value != newValue)
{
value = [newValue copy];
}
}
What does a "category" do?
Allows you to add methods to existing classes (like prototype in javascript).
Can you use "categories" to add instance variables to a class?
No.
Can methods added using "categories" access the class's private instance variables?
Yes.
What are "extensions?"
Class extensions allow you to define additional required API outside of the main @interface block. It is similar to using categories aside from the fact that you don't provide the category name.
What is a "protocol?"
It declares methods that can be implemented by any class (interface?).
What do you call something that starts with a @
a directive.
How do you declare a protocol?
@protocol name
@required
required method declarations here
@optional
optional method declarations here
@end
How does a class "adopt" a protocol?
In a class's declaration inside <> brackets.

Example:
@interface Formatter : NSObject < Formatting, Prettifying >
How do you check if a class conforms to a "protocol?"
if (![receiver conformsToProtocol:@protocol(MyProtocolName)])
Whats Objective C's equivalent to php's foreach statement?
for (Type newVarName in aCollection)
{
statements.
}
Objective C's exception support revolves around what 4 compiler directives?
@try, @catch, @throw, @finally
What does the @finally directive do?
The code inside the @finally block must be executed whether or not the exception was thrown or not.
Can you have more than 1 @catch block inside the @try block?
Yes, each for different exceptions.
Give an example of throwing an exception.
NSException *exception = [NSException exceptionWithName:@"HotTeaException"

reason:@"The tea is too hot" userInfo:nil];

@throw exception;
Does Objective C support threading?
Yes.
Explain the @synchronized directive
It takes in one argument which is a object. The object is now referred to as a mutual exclusion semaphore. The section of code will be locked when it is executing.
Give an example usage of @synchronized
@synchronized (self)
{
..critical code here..
}
What is a semaphore?
A protected (by locking) variable that will be accessed by shared resources.
What is the delegation design pattern?
A pattern where one object periodically sends messages to another object specified as its delegate to ask for input or notify the delegate that an event is occuring.
What is the target-action pattern?
The target-action mechanism enables a control object(button, slider, etc...) in response to a user event to send a message to another object.
What is a "forward declaration?"
A promise to the compiler that a class will be defined somewhere else and that it doesn't need to waste time checking for it now.
What does a "forward declaration" look like?
@class MyViewController
How do you create and initialize a view controller?
first you must call alloc then initWithNibName:bundle:
What is an outlet?
An instance of a variable that connects to a object in a nib file.
How do you create a outlet?
One way to create a outlet is to ctrl+mouse drag from the object containing the outlet to the destination object.
What is the special keyword to tell the Interface Builder that a instance variable is an outlet?
IBOutlet
What is the special keyword to tell the Interface Builder that a method is an action for target/action connections??
IBAction
what method does the text field call when a user presses done
textFieldShouldReturn
How do you dismiss the keyboard?
send resignFirstResponder message
What is a bundle?
A directory containing code and resources.
What are nib files?
They are bundles containing resources built using the interface builder.
How do u instantiate a class?
Send the classname the alloc message.
[myClass alloc]
Give the method definition of the method that is called after the user presses the keypad return button.
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField
How do you get a controllers view?
UIView *controllersView = [myViewController view];