iOS Interview Questions

34.What is block in objective c?
Blocks are a language-level feature added to C, Objective-C and C++, which allow you to create distinct segments of code that can be passed around to methods or functions as if they were values. Blocks are Objective-C objects, which means they can be added to collections like NSArray or NSDictionary. They also have the ability to capture values from the enclosing scope, making them similar to closures or lambdas in other programming languages.


36.How to parse JSON? explain in deep.
By using NSJSONSerialization.
For example : NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData: data options: NSJSONReadingMutableContainers error: &e];

37.How to use reusable cell in UITableview?
By using dequeReusableCellWithIdentifier

38.What is the meaning of "strong"keyword?
strong -o "own" the object you are referencing with this property/variable. The compiler will take care that any object that you assign to this property will not be destroyed as long as you (or any other object) points  to it with a strong reference.

39.What is the meaning of "weak" keyword? 
Weak - weak reference you signify that you don't want to have control over the object's lifetime. The object you are referencing weakly only lives on because at least one other object holds a strong reference to it. Once that is no longer the case, the object gets destroyed and your weak property will automatically get set to nil.

40.What is difference strong and  weak reference ? explain.
complier with be responsible for lifetime of object which is declared as strong. for weak object - compiler will destroy object once strong reference that hold weak object get destroyed.

41.What is ARC ? How it works? explain in deep.
Automatic reference counting (ARC)  If the compiler can recognize where you should be retaining and releasing objects, and put the retain and release statement in code.

42.What manual memory management ?  how it work?
In Manual memory management  developers is responsible for life cycle of object. developer has to retain /alloc and release the object wherever needed.

43.How to find the memory leaks in MRC?
By using -
  1.  Static analyzer.
  2. Instrument
44.what is use of NSOperation? how NSOperationque works?
An operation object is a single-shot object—that is, it executes its task once and cannot be used to execute it again. You typically execute operations by adding them to an operation queueAn NSOperationQueue object is a queue that handles objects of the NSOperation class type. An NSOperation object, simply phrased, represents a single task, including both the data and the code related to the task. The NSOperationQueue handles and manages the execution of all the NSOperation objects (the tasks) that have been added to it.

45.What is autorealease pool?
Every time -autorelease is sent to an object, it is added to the inner-most autorelease pool. When the pool is drained, it simply sends -release to all the objects in the pool.
Autorelease pools are simply a convenience that allows you to defer sending -release until "later". That "later" can happen in several places, but the most common in Cocoa GUI apps is at the end of the current run loop cycle.

46.Difference between nil and Nil.
Nil is meant for class pointers, and nil is meant for object pointers

47.What is fast enumeration?
for(id object in objets)
{
}

48.How to start a thread? 
- (void)performSelectorInBackground:(SEL)aSelector withObject:(id)arg on NSObject
NSThread* evtThread = [ [NSThread alloc] initWithTarget:self
selector:@selector( saySomething )
object:nil ];
[ evtThread start ];

49.How to download something from the internet?
By Using NSURLConnection , by starting connection or sending synchronous request.

50.what is synchronous web request and asynchronous ?
  • In  synchronous request main thread gets block and control will not get back to user till that request gets execute.
  • In Asynchronous control gets back to user even if request is getting execute.
51.Difference between sax parser and dom parser ?
  • SAX (Simple API for XML)
  • Parses node by node
  • Doesn't store the XML in memory
  • We can not insert or delete a node
  • Top to bottom traversing
52.Explain DOM (Document Object Model)
  • Stores the entire XML document into memory before processing
  • Occupies more memory
  • We can insert or delete nodes
  • Traverse in any direction
53.What are the ViewController  lifecycle in ios?
loadView - viewDidLoad-viewWillAppear-viewDidAppear - viewDisappear  - viewDidUnload

54.Difference between coredata & sqlite?
There is a huge difference between these two. SQLLite is a database itself like we have MS SQL Server. But CoreData is an ORM (Object Relational Model) which creates a layer between the database and the UI. It speeds-up the process of interaction as we dont have to write queries, just work with the ORM and let ORM handles the backend. For save or retrieval of large data, I recommend to use Core Data because of its abilities to handle the less processing speed of IPhone.

55.Steps for using coredata?
NSFetchedResultsController - It is designed primarily to function as a data source for aUITableView

56.What are the Application lifecycle in ios?
  • ApplicationDidFinishLaunchingWithOption -ApplicationWillResignActive- ApplicationDidBecomeActive-ApplicationWillTerminate
57.Difference between release and autorelease ?
  • release - destroy the object from memory,
  • autorelease - destroy the object from memory in future when it is not in use.
58.How to start a selector on a background thread
- (void)performSelectorInBackground:(SEL)aSelector withObject:(id)arg on NSObject

59.What happens if the methods doesn’t exist
App will crash with exception unrecognized selector sent to instance.

60.How Push notification works?
Server - Apple server - device by using APNs Delegate methods : 
UITableView:
DataSource -Configuring a Table View
– tableView:cellForRowAtIndexPath:  required method
– numberOfSectionsInTableView:
– tableView:numberOfRowsInSection:  required method
– sectionIndexTitlesForTableView:
– tableView:sectionForSectionIndexTitle:atIndex:
– tableView:titleForHeaderInSection:
– tableView:titleForFooterInSection:
Inserting or Deleting Table Rows
– tableView:commitEditingStyle:forRowAtIndexPath:
– tableView:canEditRowAtIndexPath:
Reordering Table Rows
– tableView:canMoveRowAtIndexPath:
– tableView:moveRowAtIndexPath:toIndexPath:
Delegate -Configuring Rows for the Table View
– tableView:heightForRowAtIndexPath:
– tableView:indentationLevelForRowAtIndexPath:
– tableView:willDisplayCell:forRowAtIndexPath:
Managing Accessory Views
– tableView:accessoryButtonTappedForRowWithIndexPath:
Managing Selections
– tableView:willSelectRowAtIndexPath:
– tableView:didSelectRowAtIndexPath:
– tableView:willDeselectRowAtIndexPath:
– tableView:didDeselectRowAtIndexPath:
Modifying the Header and Footer of Sections
– tableView:viewForHeaderInSection:
– tableView:viewForFooterInSection:
– tableView:heightForHeaderInSection:
– tableView:heightForFooterInSection:
Editing Table Rows
– tableView:willBeginEditingRowAtIndexPath:
– tableView:didEndEditingRowAtIndexPath:
– tableView:editingStyleForRowAtIndexPath:
– tableView:titleForDeleteConfirmationButtonForRowAtIndexPath:
– tableView:shouldIndentWhileEditingRowAtIndexPath:
Reordering Table Rows
tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath:
Copying and Pasting Row Content
– tableView:shouldShowMenuForRowAtIndexPath:
– tableView:canPerformAction:forRowAtIndexPath:withSender:
– tableView:performAction:forRowAtIndexPath:withSender:
UIPickerView-DataSource -Providing Counts for the Picker View
– numberOfComponentsInPickerView:
– pickerView:numberOfRowsInComponent:
Delegate -Setting the Dimensions of the Picker View
– pickerView:rowHeightForComponent:
– pickerView:widthForComponent:
Setting the Content of Component Rows
The methods in this group are marked @optional. However, to use a picker view, you must implement either thepickerView:titleForRow:forComponent: or thepickerView:viewForRow:forComponent:reusingView: method to provide the content of component rows.
– pickerView:titleForRow:forComponent:
– pickerView:viewForRow:forComponent:reusingView:
Responding to Row Selection
– pickerView:didSelectRow:inComponent:
UITextFeild-Delegate -Managing Editing
– textFieldShouldBeginEditing:
– textFieldDidBeginEditing:
– textFieldShouldEndEditing:
– textFieldDidEndEditing:
Editing the Text Field’s Text
– textField:shouldChangeCharactersInRange:replacementString:
– textFieldShouldClear:
– textFieldShouldReturn:
UItextView-Delegate - Responding to Editing Notifications
– textViewShouldBeginEditing:
– textViewDidBeginEditing:
– textViewShouldEndEditing:
– textViewDidEndEditing:
Responding to Text Changes
– textView:shouldChangeTextInRange:replacementText:
– textViewDidChange:
Responding to Selection Changes
– textViewDidChangeSelection:
MKMapView-Delegate -Responding to Map Position Changes
– mapView:regionWillChangeAnimated:
– mapView:regionDidChangeAnimated:
Loading the Map Data
– mapViewWillStartLoadingMap:
– mapViewDidFinishLoadingMap:
– mapViewDidFailLoadingMap:withError:
Tracking the User Location
– mapViewWillStartLocatingUser:
– mapViewDidStopLocatingUser:
– mapView:didUpdateUserLocation:
– mapView:didFailToLocateUserWithError:
– mapView:didChangeUserTrackingMode:animated:  required method
Managing Annotation Views
– mapView:viewForAnnotation:
– mapView:didAddAnnotationViews:
– mapView:annotationView:calloutAccessoryControlTapped:
Dragging an Annotation View
– mapView:annotationView:didChangeDragState:fromOldState:
Selecting Annotation Views
– mapView:didSelectAnnotationView:
– mapView:didDeselectAnnotationView:
Managing Overlay Views
– mapView:viewForOverlay:
– mapView:didAddOverlayViews:
NSURLConnection-Delegate -Connection Authentication
– connection:willSendRequestForAuthenticationChallenge:
– connection:canAuthenticateAgainstProtectionSpace:
– connection:didCancelAuthenticationChallenge:
– connection:didReceiveAuthenticationChallenge:
– connectionShouldUseCredentialStorage:
Connection Completion
– connection:didFailWithError:
NSURLConnectionDownloadDelegate
– connection:didWriteData:totalBytesWritten:expectedTotalBytes:
– connectionDidResumeDownloading:totalBytesWritten:expectedTotalBytes:
– connectionDidFinishDownloading:destinationURL:
NSURLConnection-Preflighting a Request
+ canHandleRequest:
Loading Data Synchronously
+ sendSynchronousRequest:returningResponse:error:
Loading Data Asynchronously
+ connectionWithRequest:delegate:
– initWithRequest:delegate:
– initWithRequest:delegate:startImmediately:
+ sendAsynchronousRequest:queue:completionHandler:
– start
Stopping a Connection
– cancel
Scheduling Delegate Messages
– scheduleInRunLoop:forMode:
– setDelegateQueue:
– unscheduleFromRunLoop:forMode:
NSXMLParser-Handling XML
– parserDidStartDocument:
– parserDidEndDocument:
– parser:didStartElement:namespaceURI:qualifiedName:attributes:
– parser:didEndElement:namespaceURI:qualifiedName:
– parser:didStartMappingPrefix:toURI:
– parser:didEndMappingPrefix:
– parser:resolveExternalEntityName:systemID:
– parser:parseErrorOccurred:
– parser:validationErrorOccurred:
– parser:foundCharacters:
– parser:foundIgnorableWhitespace:
– parser:foundProcessingInstructionWithTarget:data:
– parser:foundComment:
– parser:foundCDATA:
Handling the DTD
– parser:foundAttributeDeclarationWithName:forElement:type:defaultValue:
– parser:foundElementDeclarationWithName:model:
– parser:foundExternalEntityDeclarationWithName:publicID:systemID:
– parser:foundInternalEntityDeclarationWithName:value:
parser:foundUnparsedEntityDeclarationWithName:publicID:systemID:notationName:
– parser:foundNotationDeclarationWithName:publicID:systemID:
NSURLConnection
Connection Authentication
– connection:willSendRequestForAuthenticationChallenge:
– connection:canAuthenticateAgainstProtectionSpace:
– connection:didCancelAuthenticationChallenge:
– connection:didReceiveAuthenticationChallenge:
– connectionShouldUseCredentialStorage:
Connection Completion
– connection:didFailWithError:
MethodGroup
– connection:needNewBodyStream
–connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:  required method
– connection:didReceiveData:  required method
– connection:didReceiveResponse:  required method
– connection:willCacheResponse:  required method
– connection:willSendRequest:redirectResponse:  required method
– connectionDidFinishLoading:  required method

61.Where can you test Apple iPhone apps if you don’t have the device?
IOS Simulator can be used to test mobile applications. Xcode that comes along with iOS SDK includes Xcode IDE as well as the iOS Simulator. Xcode also includes all required tools and frameworks for building iOS apps. However, it is strongly recommended to test the app on the real device before publishing it.



62.Does iOS support multitasking? 
iOS 4 and above supports multi-tasking and allows apps to remain in the background until they are launched again or until they are terminated.

63.Which JSON framework is supported by iOS?
SBJson framework is supported by iOS.  It is a JSON parser and generator for Objective-C. SBJson provides flexible APIs and additional control that makes JSON handling easier.

64.What are the tools required to develop iOS applications?
iOS development requires Intel-based Macintosh computer and iOS SDK.

65.Name the framework that is used to construct application’s user interface for iOS.
The UIKit framework is used to develop application’s user interface for iOS. UIKit framework provides event handling, drawing model, windows, views, and controls specifically designed for a touch screen interface.

66.Name the application thread from where UIKit classes should be used?
UIKit classes should be used only from an application’s main thread.  Note: The derived classes of UIResponder and the classes which manipulate application’s user interface should be used from application’s main thread.

FabGreenTechnologies-Madivala
FabGreenTech.com

No comments:

Post a Comment