1.Difference between categories and extensions?
A:There are three difference beween categories and extensions:
- The extension has no name;
- The implementation of the extension must be in the main @implementation block of the file;
- The extension can easy declare property that need backend instance variable.
2.What is advantage of category?
- You can add method to existing class even to that class whose source is not available to you.
- You can extend functionality of a class without subclassing.
- You can split implementation in multiple files.
3.What are KVO and KVC?
Key-value observing is a mechanism that enables an object to be notified directly when a property of another object changes.
Key-value coding is a mechanism for indirectly accessing an object’s attributes and relationships using string identifiers.
Reference:Cocoa Core Competencies
4.Difference between shallow copy and deep copy?
- shallow copy reference origin object, deep copy create a new object through clone origin object
- deep copy is more complex than shallow copy
- deep copy is more expensive
5.When retain count increase?
- When you create an object;
- When you send an object retain message;
6.If we don’t create any autorelease pool in our application then is there any autorelease pool already provided to us?
A: It depends on case, if we create app base on an UI framework, there is an autorelease pool already provided to us; otherwise, we should create one by ourself.
7.When you will create an autorelease pool in your application?
A:There are three occasions when you might use your own autorelease pool blocks:
- If you are writing a program that is not based on a UI framework, such as a command-line tool.
If you write a loop that creates many temporary objects. You may use an autorelease pool block inside the loop to dispose of those objects before the next iteration. Using an autorelease pool block in the loop helps to reduce the maximum memory footprint of the application.
If you spawn a secondary thread. You must create your own autorelease pool block as soon as the thread begins executing; otherwise, your application will leak objects.
8.How many autorelease pool you can create in your application? Is there any limit?
A: You can create autorelease pool as much as possible, there is no limit.
9.What is purpose of delegates?
A:The purpose of delegates is archive the same reuse ability of subclass via composite objects.
10.What is difference between NSNotification and protocol?
- Protocol is To-one Relationships; NSNotification is To-many Relationships.
- Protocol support bidirectional data-transfer between two classes.
- Protocol doesn’t need the third object to coordinate the communication.
A: The ability of different objects to respond, each in its own way, to identical messages is called polymorphism.
A:A singleton class returns the same instance no matter how many times an application requests it.
13.Give us example of what are delegate methods and what are data source methods of UITableView?
1 2 3 4 5 6 7 8
14.What are mutable and immutable types in Objective C?
A:A mutable object can be mutated or changed. An immutable object cannot.
15.When to use NSMutableArray and when to use NSArray?
A:When collection will mutable you should use NSMutableArray, otherwise use NSArray.
16.What is convenience constructor?
A:A convenience constructor is one that performs object allocation & initialization in one step & returns an autoreleased object to the caller.
17.What is responder chain?
A:The responder chain is a series of linked responder objects.
18.What is push notification?
A:Apple Push Notification service (APNs for short) is the centerpiece of the remote notifications feature. It is a robust and highly efficient service for propagating information to iOS and OS X devices. Each device establishes an accredited and encrypted IP connection with the service and receives notifications over this persistent connection. If a notification for an app arrives when that app is not running, the device alerts the user that the app has data waiting for it.