Here I am providing you best iPhone & iPad interview question that asking too much in interview.
All question are best and so imported for us
I am providing you question if have any mistake then suggest me I will update these.
- Difference Between Integer and NSInteger ?
Answer : -
You usually want to use NSInteger when you don't know what kind of processor architecture your code might run on, so you may for some reason want the largest possible int type, which on 32 bit systems is just an int, while on a 64-bit system it's a long.
I'd stick with using NSInteger instead of int/long unless you specifically require them.
NSInteger/NSUInteger are defined as *dynamic typedef*s to one of these types, and they are defined like this:
Example : -
#if __LP64__ || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
typedef long NSInteger;
typedef unsigned long NSUInteger;
#else
typedef int NSInteger;
typedef unsigned int NSUInteger;
#endif
Answer source is : -
Use NSInteger vs. int
Qusetion 2 . Difference between strong and retain ?
Answer : -
Its entirely semantic (afaik) to the way ARC and non-ARC projects work. Apple would prefer everyone use ARC and is pushing in that direction.
In a non-ARC project "strong" will act as "retain". In an ARC project "retain" might work if clang doesn't flag an error (i dont use ARC), but theres a subtlety in the description.
Retain says - Im holding on to this object, until Im ready to release it, strong says (hey ARC treat this as a retained object and insert some generated code in my dealloc method to be released when the autorelease pool drains).
strong is a new feature in iOS 5 Automatic Reference Counting (ARC) which behave the same as retain in iOS 4
Answer Reference : - Whats the difference between strong and retain
Question 3 : - Difference between frame and bounds ?
Answer : -
The bounds of an UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to its own coordinate system (0,0).
The frame of an UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to the superview it is contained within.
So, imagine a view that has a size of 100x100 (width x height) positioned at 25,25 (x,y) of its superview. The following code prints out this view's bounds and frame:
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"bounds.origin.x: %f", label.bounds.origin.x);
NSLog(@"bounds.origin.y: %f", label.bounds.origin.y);
NSLog(@"bounds.size.width: %f", label.bounds.size.width);
NSLog(@"bounds.size.height: %f", label.bounds.size.height);
NSLog(@"frame.origin.x: %f", label.frame.origin.x);
NSLog(@"frame.origin.y: %f", label.frame.origin.y);
NSLog(@"frame.size.width: %f", label.frame.size.width);
NSLog(@"frame.size.height: %f", label.frame.size.height);
}
And the output of this code is:
bounds.origin.x: 0
bounds.origin.y: 0
bounds.size.width: 100
bounds.size.height: 100
frame.origin.x: 25
frame.origin.y: 25
frame.size.width: 100
frame.size.height: 100
So, we can see that in both cases, the width and the height of the view is the same regardless of whether we are looking at the bounds or frame. What is different is the x,y positioning of the view. In the case of the bounds, the x and y coordinates are at 0,0 as these coordinates are relative to the view itself. However, the frame x and y coordinates are relative to the position of the view within the parent view (which earlier we said was at 25,25).
Answer Source : -
difference between the frame and the bounds?
Question 4 : - Difference between category and protocol ?
Answer : -
A protocol is the same thing as an interface in Java: it's essentially a contract that says,
"Any class that implements this protocol will also implement these methods."
A category, on the other hand, just binds methods to a class. For example, in
Cocoa, I can create a category for NSObject that will allow me to add methods to the NSObject class (and, of course, all subclasses), even though I don't really have access to NSObject.
To summarize: a protocol specifies what methods a class will implement; a category adds methods to an existing class.
The proper use of each, then, should be clear:
Use protocols to declare a set of methods that a class must implement, and use categories to add methods to an existing class.
Answer Source : -
Protocol versus Category
Question 5 : - Difference between [self method] or performSelector@selector(method)?
Answer : -
Basically
performSelector allows you to
dynamically determine which
selector to call a selector on the given object. In other words the selector need not be determined before runtime.
Thus even though these are equivalent:
[anObject aMethod];
[anObject performSelector:@selector(aMethod)];
The second form allows you to do this:
SEL aSelector = findTheAppropriateSelectorForTheCurrentSituation();
[anObject performSelector: aSelector];
Answer Source : -
Using -performSelector: vs. just calling the method
Question 6 : - Difference between synchronous and asynchronous in objective c
Answer : -
You should always use asynchronous loading of network requests.
Asynchronous never block the main thread waiting for a network response.
Asynchronous can be either synchronous on a separate thread, or scheduled in the run loop of any thread.
Synchronous blocks main thread until they complete request.
Answer Source : -
what is synchronous and asynchronous in iphone and iPad?
Question 7 : - Difference between GET and POST in ios ?
Answer : -
POST METHOD: The POST method generates a FORM collection, which is sent as a HTTP request body. All the values typed in the form will be stored in the FORM collection.
GET METHOD: The GET method sends information by appending it to the URL (with a question mark) and stored as A Querystring collection. The Querystring collection is passed to the server as name/value pair. The length of the URL should be less than 255 characters.
Answer : -
dequeueReusableCellWithIdentifier: only returns a cell if it has been marked as ready for reuse. This is why in almost every cellForRowAtIndexPath: method you will see something like
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (nil == cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
}
return cell;
In effect, enough rows will be allocated to fill the visible part of the tableview (plus one or two more). As cells scroll off screen, they are removed from the table and marked as ready for reuse. As the queue of "available cells" grows, your line that asks for a dequeued cell will start obtaining a cell to use, at which point you will not have to allocate anymore.
Answer Source : -
UITableView dequeueReusableCellWithIdentifier Theory
Question 9 : - What is Protocol in Objective C ?
Answer : -
In Objective-C, a particular class only has one parent, and its parent has one parent, and so on right up to the root object (NSObject). But what if your class needs to call methods on objects outside of its parent tree? A protocol is one way Objective-C solves this problem.
A protocol is a list of method declarations. If your class adopts the protocol, then you have to implement those methods in your class.
In Objective-C 2.0 and later, some protocol methods can be marked as optional. This means you don't have to implement those, but you still have to implement all of the required methods. When you do, your class is said to conform to the protocol.
Protocols are used quite a bit in iPhone development. For instance, a UITableView requires a data source and a delegate object; these must conform to the UITableViewDataSource and UITableViewDelegate protocols.
To adopt a protocol, add it to your class header file:
@interface FavoritesViewController : UIViewController
The protocol names appear after the class declaration, inside angled brackets. When adopting more than one protocol, list them in a comma-separated list.
Then in your implementation (.m) file, implement all of the required methods for each protocol. (For Cocoa classes, consult the documentation to see which methods are required and which are optional.)
Answer Source : -
Objective-C: Protocols
Question 10 : - What is notification center in iOS ?
Answer : -
Notifications are an incredibly useful way to send messages (and data) between objects that otherwise don't know about each other. Think of it like a radio station broadcasting messages: the station (sender)
broadcasts the message, and listeners can choose to listen in and receive some (or all) of the broadcast messages.
For example, you might have a network reachability check in your app delegate, and post notifications whenever the reachability changes. Other objects would listen for that notification and react accordingly when the network goes up or down.
Some
Cocoa frameworks send notifications when certain events happen. In iOS 4.0 and up, the application sends
notifications when an app is about to move the background... and when it returns from the background. Your app's objects and controllers can listen for these notifications and stop actions (or save data) when the app is about to quit, and resume when it becomes active again.
Answer Source : -
Notifications
Thanks for Visit , Also can visit on My blog Facebook page iPhone & iPad Application Development Help World and also can visit Google+