Top IOS Interview Questions and Answers (Jan 2019) Part 2
Top IOS Interview Questions and Answers (Jan 2019) Part 2
This article includes recently asked question in VMware for IOS position. Hope it will help you.
Q1. What is method swizzling, where have you used it?
Ans: Method swizzling is the process of changing the implementation of an existing selector. It’s a technique made possible by the fact that method invocations in Objective-C can be changed at runtime, by changing how selectors are mapped to underlying functions in a class’s dispatch table.
Reference:
https://www.uraimo.com/2015/10/23/effective-method-swizzling-with-swift/
https://nshipster.com/method-swizzling/
Q2. What is the code review process , what all are the main things which you consider during reviewing swift based iOS application?
Ans: There is no perfect answer, but you can try to cover as much as possible like memory footprint, app performance, optionals etc.
- Delegates implemented in extensions
- Are all methods that should be private, file private or final
- Is the use of optionals minimal or Properly handled
- Is the use of ! forced unwrap rational and not crash-able.
- Use of Any or AnyObject should be minimal. Use specific types or protocols. Or even better use generics
- Are only methods public that need to be tested
- Are there any classes that seem overly long? Maybe some functionality should be split into separate classes.
- Is the app compiled with ARC, MRR, or a mix? If not all ARC, why not
- Does the app make good use of common Cocoa patterns, such as MVC, notifications, KVO, lazy-loading, etc? Are there any efforts underway to adopt patterns that aren’t backed by Apple, but are gaining steam in the iOS world, such as Reactive Cocoa andMVVM?
- Are there view-controllers that are overloaded with too much responsibility?
- Check for static dispatch and dynamic dispatch
Q3. What is the unit testing framework for iOS app, Have you used it?
Ans: Some of the popular Test Frameworks for IOS application.
- Appium : is an open-source testing tool. It provides automations of application testing process on Android and IOS. It allows the user to check each individual parts of the program’s source code, and systematically done during the process of programming.
- Calabash : is an IOS automation testing tool. The testing process of this framework is done based on Cucumber (an extensive automation testing tool)
- XCTest : is the IOS functional testing framework. This framework can be used for testing at any state of the development process.
- EarlGrey : is the best UI testing framework. This open-source framework is easy to integrate with IOS.
- Jest : is an automated testing framework. Using this framework, we can ensure that the user interface cannot be changed unexpectedly.
Q4. What is Mocking?
Ans: Mocking is primarily used in unit testing. An object under test may have dependencies on other (complex) objects. To isolate the behavior of the object you want to replace the other objects by mocks that simulate the behavior of the real objects. This is useful if the real objects are impractical to incorporate into the unit test.
In short, mocking is creating objects that simulate the behavior of real objects.
Reference: https://www.raywenderlich.com/1752-unit-testing-tutorial-mocking-objects
Q5. Tell me about generics in swift , where have you used?
Ans: Generic functions can work with any type. Please refer https://docs.swift.org/swift-book/LanguageGuide/Generics.html for more details.
Q6. Difference between UICollectionViewDelegateFlowLayout UICollectionViewFlowLayout?
Ans: UICollectionViewFlowLayout : A concrete layout object that organizes items into a grid with optional header and footer views for each section.
The UICollectionViewDelegateFlowLayout protocol defines methods that let you coordinate with a UICollectionViewFlowLayout object to implement a grid-based layout. The methods of this protocol define the size of items and the spacing between items in the grid..
Q7. What is the benefit of CoreData over Sqlite?
Ans:
Q8. What are the different ways to achieve concurrency in iOS?
Ans: iOS Concurrency: NSOperation and Dispatch Queues
- Concurrency and Application Design introduces the basics of asynchronous application design and the technologies for performing your custom tasks asynchronously.
- Operation Queues shows you how to encapsulate and perform tasks using Objective-C/Swift objects.
- Dispatch Queues shows you how to execute tasks concurrently in Swift/ObjectiveC/ C-based applications.
- Dispatch Sources shows you how to handle system events asynchronously.
- Migrating Away from Threads provides tips and techniques for migrating your existing thread-based code over to use newer technologies.
Q9. What is SSL Certificate, Where do we use it , Have you ever used it?
Ans: SSL Provides Authentication
In addition to encryption, a proper SSL certificate also provides authentication. This means you can be sure that you are sending information to the right server and not to an imposter trying to steal your information.
Reference: https://www.sslshopper.com/why-ssl-the-purpose-of-using-ssl-certificates.html
Q10. What is the difference between Delegate and Notification?
Ans: The concept of delegation as its name suggests allows an object to send a message to another object (the delegate) so that it can customise the handling of an event.
The concept of notification differs from delegation in that it allows a message to be sent to more than one object. It is more like a broadcast rather than a straight communication between two objects. It removes dependencies between the sending and receiving object(s) by using a notification center to manage the sending and receiving of notifications. The sender does not need to know if there are any receivers registered with the notification center. There can be one, many or even no receivers of the notification registered with the notification center.
The other difference between notifications and delegates is that there is no possibility for the receiver of a notification to return a value to the sender.
Q11. What is Bitcode and its advantages?
Ans: Bitcode is an intermediate representation of a compiled program. Apps you upload to iTunes Connect that contain bitcode will be compiled and linked on the App Store. Including bitcode will allow Apple to re-optimize your app binary in the future without the need to submit a new version of your app to the App Store.
For iOS apps, bitcode is the default, but optional. For watchOS and tvOS apps, bitcode is required. If you provide bitcode, all apps and frameworks in the app bundle (all targets in the project) need to include bitcode.
Reference:https://help.apple.com/xcode/mac/8.3/index.html?localePath=en.lproj#/devbbdc5ce4f
Q12. What is the difference between asymmetric encryption and symmetric encryption? Which algorithm you have used?
Ans: The fundamental difference that distinguishes symmetric and asymmetric encryption is that symmetric encryption allows encryption and decryption of the message with the same key. On the other hand, asymmetric encryption uses the public key for the encryption, and a private key is used for decryption.
Reference: https://techdifferences.com/difference-between-symmetric-and-asymmetric-encryption.html
Q13. What are the new changes in Swift 4.2 which was not there in swift 4.0?
Ans:
- Swift 4.2 adds enumeration cases arrays to enumerations [SE-0194]
- Swift 4.2 uses dynamic member lookup to provide dot syntax for subscripts instead in [SE-0195]
-
Swift 4.2 renames some of these methods for consistency [SE-0204]: Add
last(where:)
andlastIndex(where:)
Methods - Swift 4.2 adds several conditional conformance improvements to extensions and the standard library [SE-0143]. like Conditional conformance in extensions.
- Swift 4.2 fixes this by defining universal hash functions [SE-0206].
Q14. What is DataSource?
Ans: A data source is like a delegate except that, instead of
being delegated control of the user interface, it is delegated
control of data. A data source is an outlet held by
NSView
and
UIView
objects such as table views and outline views that require a
source from which to populate their rows of visible data. The
data source for a view is usually the same object that acts as
its delegate, but it can be any object. As with the delegate,
the data source must implement one or more methods of an
informal protocol to supply the view with the data it needs and,
in more advanced implementations, to handle data that users
directly edit in such views.
As with delegates, data sources are objects that must be present to receive messages from the objects requesting data. The application that uses them must ensure their persistence, retaining them if necessary in memory-managed code.
Data sources are responsible for the persistence of the objects they hand out to user-interface objects. In other words, they are responsible for the memory management of those objects. However, whenever a view object such as an outline view or table view accesses the data from a data source, it retains the objects as long as it uses the data. But it does not use the data for very long. Typically it holds on to the data only long enough to display it.
If you have any comment, question, or recommendation, feel free to post them in the comment section below! You can also follow me on Medium for new articles and connect with me on LinkedIn.