Sunday 8 November 2015

Interview Queations 2


1) Whats the NSCoder class used for?

NSCoder is an abstractClass which represents a stream of data. They are used in Archiving and Unarchiving objects. NSCoder objects are usually used in a method that is being implemented so that the class conforms to the protocol. (which has something like encodeObject and decodeObject methods in them). 
 

2) Whats an NSOperationQueue and how/would you use it?

The NSOperationQueue class regulates the execution of a set of NSOperation objects. An operation queue is generally used to perform some asynchronous operations on a background thread so as not to block the main thread.  
 

3) Explain the correct way to manage Outlets memory

Create them as properties in the header that are retained. In the viewDidUnload set the outlets to nil(i.e self.outlet = nil). Finally in dealloc make sure to release the outlet.

4)What is Automatic Reference Counting (ARC)?

Is a compiler-level feature that simplifies the process of managing the lifetimes of Objective-C objects. Instead of you having to remember when to retain or release an object, ARC evaluates the lifetime requirements of your objects and automatically inserts the appropriate method calls at compile time.
 

5) Multitasking support is available from which version?

 iOS 4.0
 

6) How many bytes we can send to apple push notification server?

256bytes.
 

7) What the difference is between retain & assign?

Assign creates a reference from one object to another without increasing the source's retain count.
if (_variable != object) {     [_variable release];     _variable = nil;     _variable = object;   }
Retain creates a reference from one object to another and increases the retain count of the source object.
if (_variable != object) {     [_variable release];     _variable = nil;     _variable = [object retain];   }
 

8)Why do we need to use @Synthesize?

We can use generated code like nonatomic, atmoic, retain without writing any lines of code. We also have getter and setter methods. To use this, you have 2 other ways: @synthesize or @dynamic: @synthesize, compiler will generate the getter and setter automatically for you, @dynamic: you have to write them yourself.
@property is really good for memory management, for example: retain.

9)How can you do retain without @property?
if (_variable != object) {     [_variable release];     _variable = nil;     _variable = [object retain];   } 
 
10)How can you use it with @property?
self.variable = object; 
When we are calling the above line, we actually call the setter like [self setVariable:object] and then the generated setter will do its job 

No comments:

Post a Comment