Online Interview Questions

Prepare interviews on Anything, AnyWhere

PHPSCOTS,Blogger, Developer Views: 1156
IOS Interview Questions

Important iOS interview questions

Whether you are a candidate or an interviewer you may always find it difficult to lay hands on the best kind of questions for an interview, especially such an important one. iOS interview questions are all technical based that are very straightforward if you have basic idea of what you are dealing with. Any amount of preparation is a waste of time if you are not through with the basics. Here is a list of important questions that will refresh your brain to prepare for the iOS interview. The questions will give you an idea about the pattern and the right way to answer the questions that may be thrown your way during the interview. So, without adieu lets’ start with the questions and answers that may come in the iOS interview.

Q1. What is the method for preventing the QuickTime Player from capturing streaming videos of iOS 8 apps on Yosemite while screen recording is on?

Ans. The QuickTime Player on Yosemite cannot record encrypted media by the HTTP Live Streams during screen recording. As a result, these will simply black out in the recorded video.

The HTTP Live Streaming tech (HLS) from Apple allows you to send and receive on-demand and live video and audio media on your iPad, iPhone, Apple TV, Mac and PC. HLS uses the very same properties and procedures which drive the web and thus, lets the user make use of content with the help of ordinary content delivery networks and web servers. HLS is exclusively designed for high reliability and it dynamically modifies itself to suit the network conditions. This is done by optimization of playback according to the available connection speed offered by wired or wireless devices.

Q2. How can a user respond or react to the state transitions on the app?

Ans. A user can state changes in the most apt way in order to respond to the state transitions. Calling the corresponding methods or functions on the app’s delegate object is one way of doing this.

For instance:

  • The method applicationDidBecomeActive( ) can be employed to arrange the app to run as the fore app.
  • The method applicationDidEnterBackground( ) can be employed for the execution of some code during the background runtime of the app and the exercise may be put on hold at any time.
  • The method applicationWillEnterForeground( ) can be employed when the app is moving into the foreground and shifting out of background and some code needs to be executed.
  • The method applicationWillTerminate( ) is called to action when the app is nearing termination.

Q3.What are extra features added in iOS 9?

Ans. Learning user habits and most importantly, acting on the information gathered has never been easier! With the excellent mechanisms of Intelligent Search as well as Siri-Intelligent Search, life is much more tech dependent and hence, easier. These can basically be used to open apps directly without command, for recommendations on restaurants or any kind of reservations and for guiding the user through the daily lives in order to ensure a smooth routine. Siri is a famous personal assistant to the iOS users.

It is capable of creating contextual reminders and even employ search to find a particular photo or video from the gallery in innovative ways. It does more than ensuring that we are where we need to be at any particular time. Going right from the home screen of the device shows “Siri Suggestions”. This screen is home to all your favourite apps and contacts, restaurants, information about the location and more important news from the web.

For more extensive search, Siri can display capabilities for deeper search and come up with results like videos, sports scores, content from other third-party apps, and more. Simple conversations and calculations can also be done using the handy search tools available on iPad or iPhone. Many inbuilt apps have also been upgraded for improved performance.

  • ✓ The app for Notes has new sketching features and checklists.
  • ✓ The maps include transit directions in addition to the usual features.
  • ✓ File attachments are possible with Mail.
  • ✓ The brand new app for News intelligently studies your interests and then personalizes the news to relevant content which is of interest to you.
  • ✓ The transaction app, Apple Pay, now comes with added store credit cards as well as loyalty cards.
  • ✓ iOS 9 has updated the leading app “Passbook” to “Wallet”.
  • In addition to these, the operating system has updated to wireless CarPlay support for an elective app from iCloud Drive, San Fransico type font, inbuilt two-factor type authentication as well as elective longer passwords for improved security.

Q4. How is retain different from assign?

Ans. Assign is the default in terms of Objective C, and thus should be used for attributes that are not pointers; whereas retain is required when the attribute is a pointer to any specific object.

Q5. What is managed object context and what are its functions?

Ans.  A managed object context is a provisional ‘scratchpad’ of sorts in any application for a collection or set of related objects. It is represented generally by an instance of the method NSManagedObjectContext( ). These related objects together represent a consistent view from the inside of one or even more persistent stores.

  • Multiple copies of any object could exist in various contexts but a singular instance of the managed object exists in not more than one context.

The chief functions of a managed object context comprise of the following:

  • Management of life cycle: In this case, the context delivers proof, undo/redo and handling of the inverse relationship.
  • Notifications: These denote the context posts notices at different points which can be observed from another part of the application.
  • Concurrency: When the Core Data makes use of confinement of threads or serialized queues in order to protect the managed object contexts and the managed objects too.

Q6. How are non-atomic and atomic properties different? Which one is the default property for synthesized properties? When would a user operate one over the other?

Ans. Properties which are stated as atomic are those which always return, with certainty, fully initialized object. The atomic property is also the default specification for all synthesized properties. It is generally good to specify them as atomic in order to completely remove the odds for confusion. However, this guarantee by atomic properties comes at the expense of performance. But in the case of properties which do not offer risks while retrieving any uninitialized value, setting them to non-atomic properties can actually boost the performance. An example of this is the case where all accesses to the particular property are synced through other means in advance.

Q7. Does Objective-C contain private methods?

Ans. Absolutely no, the private method in Object-C programming is not a method. The method becomes protected only when it is defined in .m. If a method is in .h, then it becomes public.
If you are really looking for a private method then you will have to add an unnamed category /local category/class extension in the class and add the method in the category and define it in the class.m.

Q8. Explain IGListKit?

Ans. The IGListKit is known to provide for different objects automatically that can be used to create deletions, moves, and insertions before it starts performing the batch updates on collection view. If a user happens to delete an update, which is in the queue that is being viewed, then we make sure that it fades out without the requirement of pulling down to refresh.
This way we can say goodbye to UICollectionViewDatasource, instead, we can use an IGListAdapterDataSource with IGListAdapter. The data source provides the array of Selection Controllers and doesn’t return counts or cells.
The Section Controllers are used to control cells and configure within the given collection view section.

Q9. What is URLSession?
Ans. When you want to upload a data in the request body, which is protocol URLSessionDataDelegate that is known as an URL Session. It is a defining method of protocols that an URLSession instances call the delegates that can handle task-level events, which are specific to upload tasks and data. So, when we are planning to retrieve contents from a particular URL, we generally choose URLConnection to use. Basically, there are 3 types of tasks;

  • Getting data to memory also known as Data task
  • Downloading file to disk  also known as Download tasks
  • uploading a file from the disk and then receiving the response as data in the memory, which is known as Upload tasks

Q10. How to download images in iOS?

Ans. URL session can be used to download an image as data and then it can be converted into UIImage from NSData. After that, we need to connect it UIImageView IBOutlet. A much better way is by using a library. With the help of built-in connectivity monitoring and URLSession Adaptable Connectivity API, we can run a request, in case of no connection. The request will download after waiting whenever the resource is available instead of failing.

Q11. Define Iterator Protocol?

Ans. Iterator protocol is best understood as one that is tightly linked with the Sequence protocol. As the sequences are known to provide access to its elements after creating an iterator, as it also keeps a track of the iteration process and returns one element at a time as it advances through the sequence. A set of good examples are available on the differences of IteratorProtocol from ‘for loop’ and ‘while loop’.

Q12. What is OAuth?

Ans. Open Authorization is often referred to as OAuth, which is generally an authorization protocol and not used for authentication. As OAuth is an authorization protocol, it is just concerned with authorization of third-party application that can be used to access user data without identifying the user or exposing its credentials. It has two libraries namely, OAuth2 and OAuthSwift

Q13. Provide an explanation for rethrows keyword

Ans. Rethrows is a very special keyword that can be used in conjunction beside closures that can throw errors. Generally with rethrow exception we can throw inside the closure as and when the error handlers are summoned inside the function. The keyword indicates to the compiler that if the closure is passed in throws, which is basically a throwing function of outer function then an error is propagated to the current scope.

Q14. Describe @objc inference

Ans. To indicate the availability of Swift declaration to Objective-C it is tagged with make it readily available to Objective-C, in Swift 3 many declarations inferred automatically. The most common place for this is any Swift method we want to refer to using a selector.

Q15. Ellaborate Viper Architecture

Ans. Viper architecture is another design pattern, which has five layers namely, Interactor, View, Router, Entity, and Presenter. It is completely based on Single Responsibility Principle.

The main advantage of viper architecture is its ability for communication from one entity to another that is made known through protocols. The idea is to isolate the app’s dependencies by balancing the delegation of responsibilities among the entities.

Q16. Define Content offset

Ans. While scrolling a scrollView the properties may get modified in the process and it is known as content offset. The scrollView can compute the new bounds and redraw any of its subviews. It is a point at which the origin of the contentView, i.e., the bounds rectangle, is offset from the origin of the scrollView.

Q17. What is NSLayoutAnchor?

Ans. When Apple brought iOS 9, with it was introduced the NSLayoutAnchor class to that made writing auto-layout easier with the code.

There are three subclasses of NSLayoutAnchor:

  • NSLayoutYAxisAnchor This subclass is used to create vertical constraints
  • NSLayoutDimension This subclass is used to create the width and height constraints
  • NSLayoutXAxisAnchor This subclass is used to create horizontal constraints

Q18. What’s the difference between MKAnnotation and MKPointAnnotation?

Ans. The major difference between MKAnnotation and MKPointAnnotation is that MKAnnotation is a protocol whereas MKPointAnnotation is a class that implements MKAnnotation. MKAnnotation protocol is implemented by NSOject subclass that is created by us. Instances of this custom class will then serve as your map annotation.

We can use MKPointAnnotation directly if we want our own business logic on the annotation.

Q19. What is Main Thread Checker?

Ans. The Main Thread Checker is a new tool launched with Xcode 9 is Main thread checker, which detects the invalid use of Apple’s frameworks like AppKit, UIKit, etc., that supposed to be used from main thread but accidentally used in the background thread. The effect of the invalid usage can result in missed visual defects, UI updates, crashes, and data corruption.

Q20. What is the difference Stack and Heap?

Ans. Our code takes up some space in the iOS. The size of this is sometimes fixed and sometimes it can change according to what the user will enter during the program. Basically we have two different methods because of this difference: Stack and Heap.
Stack is used and automatically removes itself from memory after work is finished. But in Heap the user could do it by writing manual code for deleting from memory.
• Stack is easy to use.• Compared to Stack, it is quite slow.
• It’s kept in RAM on the computer.• It creates memory problems if not used correctly.
• Created variables are automatically deleted when they exit the stack.• Variables are used with pointers.
• It is quite fast compared to Heap.• It is created at runtime.
• Constructed variables can be used without a pointer.

Q21. Provide a good explanation for VIP (Clean-Swift) Architecture

Ans. Interactor can be directly interacted by ViewController after sending requests. The Interactor then responds to the requests by sending presenter a Response with data model. The Presenter formats data to be displayed creates a ViewModel and notifies the ViewController that it should update its View based on the ViewModel. ViewController decides when the navigation to a different scene should happen by calling a method on a Router. The Router performs setup of the next View Controller and deals with wiring, passing data and delegation setup. When compared to VIPER, the difference is that the ViewController itself contacts Router for navigation.

Q22. Define Decoding or Deserialization and Encoding or Serialization,

Ans. The process of data conversion into a single JSON or string is called Serialization. It can be transmitted or stored easily. Another word for Serialization is encoding. A single string when through the reversible process is turned into a data is known as deserialization or decoding.

In swift we use the Codable protocol that a type can conform to, to declare that it can be encoded and decoded. It’s basically an alias for the Encodable and Decodable protocols.

Q23. What is the purpose of using IBAction and IBOutlet?

Ans. IBOutlet and IBAction are macros that are defined to denote methods and variables that can be referred to in the Interface Builder.

IBAction resolves to void whereas IBOutlet resolves to nothing, but yes, they signify to Xcode and Interface Builder that these methods and variables can be used in Interface builder to link UI elements to your code.

Q24. Explain AlamoFire Benefits

Ans. For iOS and macOS, Alamofire is a networking library, which is based on HTTP Swift. It is known to provide an elegant interface to simplify a lot of common tasks of networking, on top of Apple’s Foundation networking stack.

  • AlamoFire is needed to create a route, which means that if we create request then it can be executed to the server by one static function.
  • It can provide methods for chaining for the request that is returned. This makes it easy for adding handling responses and headers.
  • It also has the number of response handlers, which is generally returned in parse JSON, text, binary form, and even multiple of each can be used for a given request.
  • AlamoFire also has a method for chaining that allows response validation. We can call validation to check for the status code of the HTTP response, the content type, or any custom validation you might need to do for our app.
  • AlamoFire gives a couple of URLRequestConvertible, protocols, and URLConvertible. These protocols can be passed on while creating a request.
  • AlamoFire is known to provide extensions that can be passed on to create the request.

These questions are not mandatory ones but to give you a general idea about the pattern and questions that may be asked in the interview. A smart outlook and presence of mind is the key to crack any interview. So with a little bit of preparation and the right approach, you can easily excel in the interview.