* What are Categories and Extensions?
Ans. A category allows you to add methods to an existing class—even to one for which you do not have the source. Categories are a powerful feature that allows you to extend the functionality of existing classes without subclassing. Using categories, you can also distribute the implementation of your own classes among several files.
See this link : Categories and Extensions
Ans. A category allows you to add methods to an existing class—even to one for which you do not have the source. Categories are a powerful feature that allows you to extend the functionality of existing classes without subclassing. Using categories, you can also distribute the implementation of your own classes among several files.
See this link : Categories and Extensions
* What are protocols ?
Ans. Protocols declare methods that can be implemented by any class. Protocols are useful in at least three situations:
Ans. Protocols declare methods that can be implemented by any class. Protocols are useful in at least three situations:
-
To declare methods that others are expected to implement.
-
To declare the interface to an object while concealing its class.
-
To capture similarities among classes that are not hierarchically related.
See this link : Protocols
* Whats the difference between frame and bounds?
Ans. The frame of a view is the rectangle, expressed as a location (x,y) and size (width,height) relative to the superview it is contained within. The bounds of a view is the rectangle, expressed as a location (x,y) and size (width,height) relative to its own coordinate system (0,0).
Ans. The frame of a view is the rectangle, expressed as a location (x,y) and size (width,height) relative to the superview it is contained within. The bounds of a view is the rectangle, expressed as a location (x,y) and size (width,height) relative to its own coordinate system (0,0).
* Outline the class hierarchy for a UIButton until NSObject.
Ans. UIButton inherits from UIControl, UIControl inherits from UIView, UIView inherits from UIResponder, UIResponder inherits from the root class NSObject.
Ans. UIButton inherits from UIControl, UIControl inherits from UIView, UIView inherits from UIResponder, UIResponder inherits from the root class NSObject.
* Can you explain what happens when you call autorelease on an object?
Ans. When you send an object a autorelease message, its retain count is decremented by 1 at some stage in the future. The object is added to an autorelease pool on the current thread. The main thread loop creates an autorelease pool at the beginning of the function, and release it at the end. This establishes a pool for the lifetime of the task. However, this also means that any autoreleased objects created during the lifetime of the task are not disposed of until the task completes. This may lead to the taskʼs memory footprint increasing unnecessarily. You can also consider creating pools with a narrower scope or use NSOperationQueue with itʼs own autorelease pool.
Ans. When you send an object a autorelease message, its retain count is decremented by 1 at some stage in the future. The object is added to an autorelease pool on the current thread. The main thread loop creates an autorelease pool at the beginning of the function, and release it at the end. This establishes a pool for the lifetime of the task. However, this also means that any autoreleased objects created during the lifetime of the task are not disposed of until the task completes. This may lead to the taskʼs memory footprint increasing unnecessarily. You can also consider creating pools with a narrower scope or use NSOperationQueue with itʼs own autorelease pool.
* Whats an NSOperationQueue and how/would you use it?
Ans. 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.
* How many bytes we can send to apple push notification server.
Ans. 256 bytes.
Ans. 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.
* How many bytes we can send to apple push notification server.
Ans. 256 bytes.
* What is advantage of categories? What is difference between implementing a category and
inheritance?
Ans: 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 classes. While in Inheritance you subclass from parent class and extend its functionality.
Ans: 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 classes. While in Inheritance you subclass from parent class and extend its functionality.
* What is the difference between delegates and notifications?
Ans: We can use notifications for a variety of reasons. For example, you could broadcast a notification to change how user-interface elements display information based on a certain event elsewhere in the program. Or you could use notifications as a way to ensure that objects in a document save their state before the document window is closed. The general purpose of notifications is to inform other objects of program events so they can respond appropriately.But objects receiving notifications can react only after the event has occurred. This is a significant difference from delegation. The delegate is given a chance to reject or modify the operation proposed by the delegating object. Observing objects, on the other hand, cannot directly affect an impending operation.
Ans: We can use notifications for a variety of reasons. For example, you could broadcast a notification to change how user-interface elements display information based on a certain event elsewhere in the program. Or you could use notifications as a way to ensure that objects in a document save their state before the document window is closed. The general purpose of notifications is to inform other objects of program events so they can respond appropriately.But objects receiving notifications can react only after the event has occurred. This is a significant difference from delegation. The delegate is given a chance to reject or modify the operation proposed by the delegating object. Observing objects, on the other hand, cannot directly affect an impending operation.
* What are the App states. Explain them?
Ans.
Ans. There are four types of In-App Purchases:
Ans.
- Not running State: The app has not been launched or was running but was terminated by
the system.
-
Inactive state: The app is running in the foreground but is currently not receiving events. (It
may be executing other code though.) An app usually stays in this state only briefly as it
transitions to a different state. The only time it stays inactive for any period of time is when
the user locks the screen or the system prompts the user to respond to some event, such as an
incoming phone call or SMS message.
-
Active state: The app is running in the foreground and is receiving events. This is the
normal mode for foreground apps.
-
Background state: The app is in the background and executing code. Most apps enter this
state briefly on their way to being suspended. However, an app that requests extra execution
time may remain in this state for a period of time. In addition, an app being launched
directly into the background enters this state instead of the inactive state. For information
about how to execute code while in the background, see “Background Execution and
Multitasking.”
-
Suspended state:The app is in the background but is not executing code. The system moves
apps to this state automatically and does not notify them before doing so. While suspended,
an app remains in memory but does not execute any code. When a low-memory condition
occurs, the system may purge suspended apps without notice to make more space for the
foreground app.
Ans. There are four types of In-App Purchases:
Type | Example | Description |
---|---|---|
Consumable |
|
You need to purchase these items every time you want them, and you can't download them again for free. |
Non-consumable |
|
You purchase these items one time, and you can transfer them to multiple devices authorized with the same iTunes Store account. |
Non-renewing subscriptions |
|
You can purchase these items again after the subscription period ends. |
Auto-renewable subscriptions |
|
You can purchase these items with different renewal periods. Learn more about auto-renewing subscriptions. |