You are on page 1of 3



• Q: Whats the difference between frame and bounds?A: The frame of a view is the rectangle. the delegate is never retained! Ever! INTERMEDIATE • Q: If I call performSelector:withObject:afterDelay: – is the objectretained? A: Yes the object is retained.0).) • Q: Whats a struct?A: A struct is a special C data type that encapsulates otherpieces of data into a single cohesive unit.e items can be added/removed from it. expressed as a location(x. When you send an object a retain message.y) and size (width. butbuilt into C. When you create an object. When you send an object a autoreleasemessage. expressed as a location(x. Theobject is added to an autorelease pool on the current thread. its retaincount is decremented by 1 at some stage in the future. it isdeallocated. it has a retain count of 1. It creates a timer that calls aselector on the current threads run loop. Like an object.render their content.i. • Q: Whats fast enumeration?A: Fast enumeration is a language feature that allows you toenumerate over the contents of a collection. BEGINNER • Q: How would you create your own custom view?A: Subclass the UIView class. (Your code willalso run faster because the internal implementation reducesmessage send overhead and increases pipelining potential.y) and size (width. The bounds of a view is the rectangle. its retain count is decremented by 1 at some stage inthe future.height) relative to the superview it iscontained within. • Q: Can you explain what happens when you call autorelease onan object?A: When you send an object a autorelease message. • Q: Is a delegate retained?A: No. Custom layer objects can also be added to the interface to implement complexanimations and other types of sophisticated visual effects. • Q: Whats the difference between a NSArray and aNSMutableArray?A: A NSArray’s contents can not be modified once it’s beencreated whereas a NSMutableArray can be modified as needed.A: Retain counts are the way in which memory is managed inObjective-C. its retain count isdecremented by 1. The main thread . its retain countis incremented by 1.height) relative to its own coordinatesystem (0.When you send an object a release message. If an object’s retain count is reduced to 0. • Q: Explain retain counts. It may not be 100%precise time-wise as it attempts to dequeue the message fromthe run loop and perform the selector.

thisalso means that any autoreleased objects created during thelifetime of the task are not disposed of until the task completes. They are used in Archiving and Unarchiving objects. UIControl inherits fromUIView.A: In the context of an NSOperation object. • Q: Outline the class hierarchy for a UIButton until NSObject. Thisestablishes a pool for the lifetime of the task. • A: It will crash because it’s added twice to the autorelease pool and when it it dequeued the autorelease pool calls releasemore than once.) • Q: Whats the NSCoder class used for?A: NSCoder is an abstractClass which represents a stream of data. (Also important – You only release orautorelease objects you own.e self. Inthe viewDidUnload set the outlets to nil(i. However. the terms concurrent and non-concurrentdo not necessarily refer to the side-by-side execution of threads. ADVANCED • Q: Is the delegate for a CAAnimation retained?A: Yes it is!! This is one of the rare exceptions to memorymanagement rules. • Q: Explain the correct way to manage Outlets memoryA: Create them as properties in the header that are retained. Instead. You can also consider creating pools with anarrower scope or use NSOperationQueue with it’s ownautorelease pool. An operation queue is generally used toperform some asynchronous operations on a backgroundthread so as not to block the main thread. and release it at the end.Finally in dealloc make sure to release the outlet.loop creates an autorelease pool at thebeginning of the function. UIResponder inheritsfrom the root class NSObject • Q: Explain the difference between NSOperationQueueconcurrent and non-concurrent. which runs in anNSOperationQueue.NSCoder objects are usually used in a method that is beingimplemented so that the class conforms to the protocol. UIView inherits from UIResponder. • Q: Whats an NSOperationQueue and how/would you use it?A: The NSOperationQueue class regulates the execution of a setof NSOperation objects.outlet = nil). This may lead to the task’s memory footprint increasingunnecessarily. a non-concurrent operation is one thatexecutes using the environment that is provided for it while aconcurrent operation is responsible for setting up its ownexecution environment . • Q: What happens when the following code executes?1Ball *ball = [[[[Ball alloc] init] autorelease]autorelease]. (whichhas something like encodeObject and decodeObject methods inthem).A: UIButton inherits from UIControl.