
iOS
CoreData is used as a framework for managing object graphs. It helps manage a graph of object instances that is potentially very large. This allows the app to use a graph that would not completely fit in the memory, by bringing objects in and out of the memory when needed. CoreData also helps in managing the limitations on properties and relationships and in maintaining the integrity of references. This means that when objects are added to or removed from a relationship, the forward and backward links remain consistent. Therefore, CoreData is considered to be the perfect framework for creating the “model” of an MVC architecture.
CoreData uses SQLite for disk storage to implement graph management. It is possible to implement graph management using some other relational database or even a non-relational database like CouchDB. CoreData is more of an API that abstracts from the actual datastore than a database engine. Therefore you can tell how CoreData must store itself - as a plist, an SQLite database, a binary file, or a custom data store type.
Giving a detailed answer to an iOS interview question like this is good, but your answer can become great if you can add your perspective as well to the answer.
Generally, retaining an object increases its retain count by one. This helps retain the object in memory instead of being blown away. Therefore, if you only have the retained version of an object, you will share that copy of the same with whoever sent it to you.
Copying an object, on the other hand, creates an extra copy or a duplicate version of the object. While you share the original with the person who sent the object to you, you do not share the copied or duplicate version with the sender.
A signed application helps the system to know who signed the application and also to determine that no changes were made to the application after it was signed. This is a necessary step to submit the application to the App Store for iOS and Mac. There is a signature verification process in OS X and iOS to confirm that the applications do not run with invalid signatures. This builds trust for the users who know that the application is signed by a verified Apple Source and no changes were made to it since signing.
During the build process, your digital identity is used by Xcode to sign your application. The digital identity comprises a public-private key pair and a certificate. The cryptographic functions use the private key to create the signature. Apple issues the certificate that contains the public key and helps identify you as the key pair owner.
The signature protects the executable code of the application because as soon as the executable code in the application changes even slightly, the signature becomes invalid. However, changes to images or nib files do not invalidate the signatures as these resources are not signed.
The signature of an application can be removed and a different digital identity can be used to re-sign the application. For example, all applications on App Store are re-signed by Apple when they are sold.
For an iOS interview question of this type, it may be good to add if you have any prior experience of a project with similar requirements, code-signing for iOS apps in this case.
There are five app states in iOS. While the app state is managed by the OS, the important tasks are managed by the app itself so that transitions between states happen smoothly. The iOS programming guide lists the five iOS app states as follows:
iOS interview questions like the above where you need to talk about multiple states or steps are popular in iOS interviews
The main features of Swift are as follows:
The biggest feature of Swift is that it is a strongly-typed language. Being a strongly-typed language is an advantage as well as a disadvantage. Development in Swift is easy because of protocols, generics, and optionals which exist because of static typing. While static timing throws several compilation errors and compile-time warnings, it also offers more security at runtime and helps in determinism for optionals, generics, etc. This is, therefore, a big advantage of Swift. The security offered by strict type is most useful under the following circumstances:
All the above are scenariOS where developers build customer-facing iOS applications.
The disadvantage of Swift is that it can be too restrictive, especially when the app you are building needs flexibility. For example, when you build a library or a framework, it needs to be flexible and dynamic. In such a case, Objective-C which offers meta-programming capabilities can be a better choice than Swift, though presently, Objective-C seems to be going obsolete.
MVC stands for Model View Controller. It is Apple’s main software design pattern for developing iOS apps. Models represent the data for the application. Views bring things to the screen. Controllers are used to manage the flow of data between model and view. There is no direct communication between model and view, all communication is taken care of by the controller.
As a senior developer, one must know that while MVC is good for general-purpose design, it can be used only for the view layer. Therefore, using only MVC will restrict the architecture of the application and could also lead to the “Massive View Controller” problem.
Massive View Controller refers to that state of the codebase when excessive logic and responsibility are given to View Controllers that are not supposed to shoulder that responsibility. As a result, the code may become rigid, bloated, and difficult to alter. As a remedy, one can use design patterns such as Coordinator, MVP, and MVVM. For scaling the iOS code and avoiding this type of problem, architectures like VIPER and RIBs can be used.
Both, delegate and KVO, create relationships between objects. Delegation creates a one-to-one relationship in which the delegate protocol is implemented by one object, and the other object uses protocol-defined methods to send messages to the first object. KVO, on the other hand, creates a many-to-many relationship in which the message is broadcast by one object, and one or more objects receive the message and react to it. KVO is not protocol-dependent.
When preparing for your iOS interview, ensure that you go through all such concepts where you could be asked to differentiate between two things.
Apart from MVC, Singleton, Observer, and Delegate patterns that are commonly used, there are other patterns too that could be used for developing iOS applications:
Outlined below are the ways to store data in simple to complex order:
The above iOS interview question is an example of questions where you can use the traditional answer outline above and be safe, but if you add examples of having implemented each or any of the options above, you may earn the interviewer’s attention.
When you work with Structs or Enums, ARC doesn’t manage these memory types. Thus, there isn’t any need to worry about specifying whether you are using weak or unowned references for the constants or variables there.
In hierarchical relationships, where the parent references the child but the reverse does not occur, you can use strong references. In most cases, anyway, strong references are apt. However, where the relationship of two instances is optional, you must ensure that one instance is weakly referenced to the other.
When one instance is linked to another in a way that it cannot exist in the other’s absence, there is a mandatory dependency of one variable on the other. In such a case, the instance that has mandatory dependence on the other must hold an unowned reference to the other.
The primary programming language used for iOS development is Swift. Objective-C is also used, but its usage has been declining in favor of Swift.
Overlays are a technique used in operating systems to allow programs to use more memory than they would otherwise be able to.
When a program is loaded into memory, it takes up a certain amount of space. If the program is large and requires more memory than is available, overlays can be used to load only the portions of the program that are currently needed into memory. As the program executes, different portions can be swapped in and out of memory as needed.
Some of the important features of Swift include:
In Swift, conditional conformances allow you to declare that a generic type conforms to a protocol only under certain conditions. This means that a type will only conform to a protocol if some condition is met, such as the type's generic parameter satisfying certain constraints.
ButtonStyle protocol allow to customize new button styles that can be reused without the need for new views. Using this protocol, you can create a button that will appear the way you want. You will make your own style that sets a decent background for a button. You can use the buttonStyle(_:) modifier.
Where arrays are an ordered collection of values, sets are an unordered collection. Also, an array can duplicate elements, while a set cannot.
A tuple is a set of multiple values inside Swift. They occupy space between dictionaries and structures and return values from a function call.
GeometryReader reads all the size and position information and passes that information to its child views via GeometryProxy. It is a flexible view and takes over all the available space provided by the parent view
A bounding box is a rectangular frame that represents the smallest rectangle that completely encloses a particular object or shape. This object can be an image, a text character, or any other graphical element on the screen. The bounding box is defined by its position and size. The position is specified by the coordinates of the top-left corner of the rectangle, while the size is specified by the width and height of the rectangle
When a custom view is set to IBDesignable, it allows Xcode to preview it while storyboards are edited. Interface Builder helps directly with making custom layouts. You can easily provide any effects like border width shadow color, shadow width, border color, corner radius, and shadow Opacity.
It stores those settings that must be available even when the app is not running. It is a file in the Mac and GNUstep environments that stores user settings. There are three formats plist, Text, Binary, and XML. A plist can store string, number, data(binary data), boolean, dictionary(associative array), and array.
They create strings that print what you see, unlike some escape orders that make your string print in a different form. Raw strings are denoted by the # hash symbol, also known as pound symbol. It is used before and after quotation marks by using # at the starting and ending point.
Using two primary ways @Published property wrapper or calling objectwillchange. send()
@Published property wrapper: It is very useful in SwiftUI. It allows us to create observable objects that automatically announce when changes occur.
Objectwillchange: It is a property defined on the ObservableObject protocol. Whenever any @Published properties of the objects change, the compiler synthesizes a default implementation for the property, which emits a value.
When two objects strongly refer each other, they can never be deallocated. And this strong reference also enables them to keep each other alive. When objects hold strong references to each other, it means that each object has a strong ownership of the other, which creates a cycle, and this cycle is referred to as a circular reference.
No, we cannot add a stored property to a type through an extension in Swift.
Extensions in Swift can add computed properties, instance methods, class methods, and initializers to a type, but they cannot add stored properties. This is because stored properties must be initialized when an instance of the type is created, and extensions cannot provide their own initializers.
It specifies a range between values x and y (x..<y) where y is not included. The operator specifies a range that includes the first value but not the final value.It is specifically useful when you work with zero-based lists such as arrays, where it's useful to count up to the length of the list.
One benefit of using child view controllers is that it allows for better modularization and organization of code in an iOS app. By breaking down a large, complex view controller into smaller, more manageable child view controllers, it becomes easier to understand and maintain the codebase.
A reference type contains the location in the memory where data lives. A reference type is passed to a function; instead of creating a new copy of the object, it just creates another reference to that object which is shared among all the different references.
In Swift, a nested function is a function defined within the body of another function. Nested functions are useful for organizing code and encapsulating functionality within a larger function scope. Nested functions can be useful for abstracting complex logic or for breaking down large functions into smaller, more manageable parts.
They are special string patterns that tell how to search for a string. It is a sequence of characters that specifies a search pattern in the text; it finds or finds and replaces operations on strings.
It is an order of objects that receive the chance to respond to events. It is the series of events that happen once we start interacting with the application on iOS. Applications receive and handle events using responder objects.
It provides tools and resources to steer business processes toward better performance. It is an execution unit in which a program operates. It ensures that each process and application receives enough of the processor’s time to function properly and deallocates after the process is completed.
Subclass: It is the act of constructing a new class on an existing class. They inherit characteristics from the existing class, and you can further modify them with new characteristics.
Super Class: When a class inherits properties from another class, the inheriting class is known as a subclass, and the class it inherits from is called a superclass.
Each thread in iOS serves as a single path of execution. Every application in IOS starts with a single thread that runs the application's main functions.
For a single-line comment you can use double slashes (//)
And for multi-line comments you can use a forward slash followed by an asterisk (/*)
It is a process of querying and calling properties. Different queries can be chained here, but the chain fails if any link is nil.
It is a process by which a class inherits properties, methods, or any other features from some other class. It is a fundamental behavior that differentiates classes from other types in Swift. We can write different implementations while maintaining the same behaviors by reusing code we have already written.
It is used as an alternative to long if-else-if statements. It lets you inspect a value and match it with a number of cases. It's especially effective in making concise decisions based on one variable that can contain a number of possible values. Using the switch statement often results in more concise code that's easier to read.
We hope the above list of iOS interview questions and answers will give you a good jumpstart for your interview preparation. For hiring managers, these questions and answers will provide as a reference to assess the proficiency of talended iOS developers. Here we have segregated the questions into basic, intermediate, and advanced, so that you can glimpse the important iOS concepts as per the grade of difficulty.
However, if you want to save hours of your hiring time or want to apply for Elite US companies, you can take the help of Turing.
Turing helps companies match with top quality remote JavaScript developers from across the world in a matter of days. Scale your engineering team with pre-vetted JavaScript developers at the push of a buttton.
Hire top vetted developers within 4 days.
Tell us the skills you need and we'll find the best developer for you in days, not weeks.