Interview with me two - Imtiaz211/interviews GitHub Wiki

What is the latest mac os version?

macOS Ventura 13.3.

What is the synchronized() block in objective-c? What is the use of that?

The @synchronized() directive locks a section of code for use by a single thread. Other threads are blocked. Until the thread exits the protected code.

What is the use of backtick ` while declaring a variable in swift?

Backticks (`) are used as a name and to surround the keyword in the case if you want to give the same name as a reserved Swift keyword to a constant or a variable.

Memory Management is Swift?

Memory management in swift is done by Automatic reference counting or ARC. Whenever a variable holds an instance of an object the memory count for the object is increased by 1. And when variables become out of scope or set to nil, the memory count decreases 1.

Why use an instrument?

Instrument is used to check memory consumption and other schematics. Instruments is a powerful performance analysis and testing tool that's part of Xcode toolset. Instruments can help you profile your apps on all platforms - iOS, macOS, watchOS, tvOS - in order to better understand and optimize their behavior and performance.

What is memory leak?

A memory leak is a type of resource leak that occurs when a compiler programmed incorrectly manages memory allocation in such a way that memory which is no longer needed is not released.

Closures?

Closure are self-contained blocks of functionality that can be passed around and used in your code? Nested functions are closures that have a name and can capture values from their enclosing function. It is reference type.

  1. Inferring parameter and return value types from context.
  2. Implicit returns from single-expression closures.
  3. Shorthand argument names.
  4. Trailing closure syntax.

What is NSCoding?

The NSCoding protocol declares the two methods that a class must implement so that instances of that class can be encoded and decoded. This capability provides the basis for archiving (where objects and other structures are stored on disk) and distribution (where objects are copied to different address spaces).

What is NSCopying?

The NSCopying protocol declares a method for providing functional copies of an object. The exact meaning of copy can vary from class to class, but a copy must be a functionally independent object with values identical to the original at the time the copy was made. A copy produced with NSCopying is implicitly retained by the sender, who is responsible for releasing it.

IBDesignable?

IBDesignable custom views also debuted in Xcode 6. When applied to a UIView or NSView subclass, the @IBDesignable designation lets Interface Builder know that it should render the view directly on the canvas.

IBInspectable?

IBInspectable properties provide new access to an old feature: user-defined runtime attributes. Currently accessible from the identity inspector, these attributes have been available since before Interface Builder was integrated into Xcode2. They provide a powerful mechanism for configuring any key-value coded property of an instance in a NIB,XIB, or storyboard.

How to draw a circle?

With IBInspectable and IBDesignable, it’s possible to build a custom interface for configuring your custom controls and have them rendered in real-time
while designing your project.

Example
@IBInspectable var cornorRadius: CGFloat = 0 {
didSet{
layer.cornorRadius = cornorRadius;
layer.maskToBounds = cornerRadius > 0
}
}

What is UIScrollView?

The UIScrollView class provides support for displaying content that is larger than the size of the application’s window. It enables users to scroll within that content by making swiping gestures, and to zoom in and back from portions of the content by making pinching gestures. A scroll view tracks the movements of fingers and adjusts the origin accordingly.

Mention what are the type of integers Swift have?

Swift provides unsigned and signed integers in 8, 16, 32 and 64 bit forms. Similar to C these integers follow a naming convention. For instance, an unsigned integer is denoted by type UInt8 while a 32 bit signed integer will be denoted by type Int32.

What is pair programming?

Pair programming is a tool to share information with junior developers. Junior and senior developers sitting side-by-side this is the best way for the junior to learn from the senior developer.

What is iCloud?

Basically, iCloud is a service that helps users synchronize the data across devices. The main purpose is to let users easily put their data, whether it’s a file or document, so that they can access the data on any of their iOS devices. iCloud offer three kinds of storage,

  1. Key Value Storage.
  2. Document Storage.
  3. Core Data Storage.

What is Deadlock?

A deadlock is a situation in which two computer programs sharing the same resource are effectively preventing each other from accessing the resource, resulting in both programs accessing the function. the earliest computer operating system ran only one program at a time.

App Transport security?

App Transport Security (ATS): Starting in iOS 9.0 and OS X 10.11, a new security feature called (ATS) is enabled by default for all HTTP connections made with URLSession. ATS requires that HTTP connections use HTTPS.

Explain web services?

The web Services are the Application Components which enable communication using open protocols. These web services are self-describing and self-contained. Web services can be found out using UDDI. The base for development of web service functionality is Extensible Markup Language (XML,JSON).

What is UML?

The Unified Modeling Language (UML) is a general-purpose, developmental, modeling language in the field of software engineering that is intended to provide a standard way to visualize the design of a system.

What is the type method?

Type methods that are called on an instance of a particular type. You can also define methods that are called on the type itself. These kinds of methods are called type methods.

What is a library?

A Library is a section or chunk of Objective-C or Swift code that you make a call from your own code, to help you do things more quickly/easily. For example, a Bitmap Processing library will provide facilities for loading and manipulating bitmap images, saving you having to write all that code for yourself.

What is API?

An API (application programming interface) is a term meaning the functions / methods in a library that you can call to ask it to do things for you – the interface to the library.

What is UIWebView?

UIWebView class to embed web content in your app. To do so, create a UIWebView object, attach it to a window, and send it a request to load web content. You can also use this class to move back and forward in the history of web pages, and you can even set some web content properties programmatically.

What is Swift?

Swift is a programming language for development of applications for OS X, iOS, watchOS, and tvOS, these applications are developed using c and objective c. It does not have the constraints of c programming. It has features for easier development and provides more flexibility.

Explain how the Swift program is deployed?

Swift program deploys the application in a Tomcat installation by default. The deploy script bundles the client code into JavaScript, gathers all the server side classes required and packages them into file Hello.war. This file together with a GWT jar and a Swift runtime jar is copied into the Tomcat installation. If CATALINA_HOME is not set, these files require to be copied manually.

What is Framework?

A framework is usually a huge library that provides many services (rather than perhaps only one focussed ability as most libraries do). For example, Facebook provides an application framework – it provides most (if not all) of the services you need to write a vast range of applications – so one “library” provides support for pretty much everything you need to do. Often a framework supplies a base on which you build your own code, rather than you building an application that consumes library code.

What is a toolkit?

A toolkit is like an SDK – it’s a group of tools (and often code libraries) that you can use to make it easier to access a device or system.

What is SDK?

An SDK (software development kit) is a library (often with extra tool applications, data files and sample code) that aid you in developing code that uses a particular system (e.g. extension code for using features of an operating system (Windows SDK), drawing 3D graphics via a particular system (DirectX SDK), writing add-ins to extend other applications (Office SDK), or writing code to make a device like an Arduino or a mobile phone do what you want)

NSKeyedArchiver?

A concrete subclass of NSCoder, provides a way to encode objects (and scalar values) into an architecture-independent format that can be stored in a file. When you archive a set of objects, the class information and instance variables for each object are written to the archive. NSKeyed Archiver’s companion class, NSKeyedUnarchiver, decodes the data in an archive and creates a set of objects equivalent to the original set.

What is the NSCoder class used for?

NSCoder is an abstract class object which represents stream data. They are used in Archiving and Unarchiving objects.

What are the Floating point numbers and what are the types of floating number in Swift?

Floating numbers are numbers with a fractional component, like 3.25169 and -238.21. Floating point types can represent a wider range of values than integer types.

A product manager in your company reports that the application is crashing. What do you do?

  1. get the exact steps to reproduce it.
  2. Find out the device, iOS version.
  3. Do they have the latest version?
  4. get device logs if possible.
  5. A really impressive candidate would start talking about writing a unit test that reproduces the issue and debugging through it.

An NSUserActivity?

Object provides a lightweight way to capture the state of your app and put it to use later. You create user activity objects and use them to capture information about what the user was doing, such as viewing app content, editing a document, viewing a web page, or watching a video. When the system launches your app and an activity object is available, your app can use the information in that object to restore itself to an appropriate state. Spotlight also uses your user activity objects to improve search results for the user.

UIPanGestureRecognizer For Understand purpose?

UIPanGestureRecognizer is a concrete subclass of UIGestureRecognizer that looks for panning (dragging) gestures. The user must be pressing one or more fingers on a view while they pan it. Clients implementing the action method for this gesture recognizer can ask it for the current translation and velocity of the gesture.

UISwipeGestureRecognizer?

Swipe gesture will work when you drag your finger only in certain directions (swipe up, swipe down, swipe right, swipe left). For example swappable cells in tableview controllers.

What is the difference between SAX and DOM parse?

SAX (Simple API for XML) parses node by node and doesn't store the XML in memory; we can’t insert or delete a node to bottom traversing. DOM(Document object Model) stores the entire XML document into memory before processing occupies more memory we can insert or delete nodes traversed in any direction.

How to call Objective-C code from swift?

Follow the following steps:

  1. Step 1: Add Objective-C Implementation --.m: First of all, add a .m file to the class and then name it CustomObject.m.
  2. Step 2: Add Bridging Header: At the time of adding your .m file, you receive a prompt with three options of YES, NO and cancel. You need to select YES
  3. Step 3: Add Objective-C Header --.h: After that Add one more .h file and name it CustomObject.h.
  4. Step 4: Build your Objective-C Class

In Swift, an attribute is a construct which provides some additional information of declaration or its type. It is represented with @ symbol and then succeeded by the attribute name and arguments. Arguments are distinct only to some attributes. For example,

  1. @available(<attribute_name>)
  2. @available(<attribute_name>)()
  3. @available

What happens when you invoke a method on a nil pointer?

A message sent to a nil object is perfectly acceptable in Objective-C; it's treated as a no-op. There is no way to flag it as an error because it's not an error, in fact it can be a very useful feature of the language. It returns 0, nil, a structure filled with 0s, etc.

Posing?

Objective-C permits a class to entirely replace another class within an application. The replacing class is said to "pose as" the target class. All messages sent to the target class are then instead received by the posing class.

A class may only pose as one of its direct or indirect super classes.
The posing class must not define any new instance variables which are absent from the target class (though it may define or override methods).
No messages must have been sent to the target class prior to the posing.
Posing, similarly to categories, allows globally augmenting existing classes. Posing permits two features absent from categories:
A posing class can call overridden methods through super, thus incorporating the implementation of the target class.

A posing class can override methods defined in categories.

What is darwin?

Darwin is an open source Unix - like computer operating system released by Apple Inc. in 2000. It is composed of code developed by Apple, as well as code derived from NeXTSTEP,BSD, and other free software projects. Darwin forms the core set of components upon which OS X and iOS are based.

What is a getter?

Getter is a method which gets called every time you access (read value from) a property (declared with @property).

What is a setter?

Often a setter is accompanied by a getter which returns the value of the private member variables.

What is a selector?

Selectors are Objective-C internal Representation of the method Name.

What is an inline function?

The inline functions are a C++ enhancement feature to increase the execution time of a program. Functions can be instructed to the compiler to make them inline so that the compiler can replace those function definitions wherever those are being called.

UINib?

Instances of the UINib class serve as object wrappers, or containers for Interface Builder nib files.

Three D Touches?

3D touch, I know it's a hardware based feature and support is there only for the latest iPhone 6S & iPhone 6S Plus models.

LLVM and Clang?

Clang is the front end of LLVM tool chain (“clang” C Language Family Frontend for LLVM). Every Compiler has three parts.
Front end (lexical analysis, parsing).
Optimizer (Optimizing abstract syntax tree).
Back end (machine code generation).

Mention what is the use of the PO command in Xcode?

PO command is useful during debug time. In a normal scenario, to print the value of a variable, you have to move the mouse pointer there and select print description print value of it. With the PO command, you can print the value by just writing the “PO variable name” in the output window, and press enter.

What is ORM?

Object-relational mapping in computer science is a programming technique for converting data between incompatible type systems using object oriented programming languages. This creates in effect a virtual object database that can be used from within the programming language.

What is the purpose of the UIWindow object?

The presentation of one or more views on screen is coordinated by the UIWindow object.

The Layout Cycle?

Run Loop -> Constraints Change -> Deferred Layout Pass Constraint changes: activating / deactivating, adding/removing views ,changing certain controls.

Explain Auto Layout?

Auto Layout provides a flexible and powerful layout system that describes how views and the UI controls calculate the size and position in the hierarchy. A constraint defines a relationship between two user interface objects that must be satisfied by the constraint-based layout system. Each constraint is a linear equation.

What is aspect ratio?

Aspect ratio constraint is used to control the width and height of a view as per an aspect ratio that you set here. There are some standard presets such as 1:1 which means width will be equal to height.

setNeedsLayout()?

The method setNeedsLayout for a UIView tells the system that you want it to layout and redraw that view and all of its subviews, when it is time for the update cycle. This is an asynchronous activity, because the method completes and returns immediately, but it isn’t until some later time that the layout and redraw actually happens, and you don’t know when that update cycle will be.

layoutIfNeeded()

In contrast, the method layoutIfNeeded is a synchronous call that tells the system you want a layout and redraw of a view and its subviews, and you want it done immediately without waiting for the update cycle. When the call to this method is complete, the layout has already been adjusted and drawn based on all changes that had been noted prior to the method call.

layoutSubviews()

The default implementation uses any constraints you have set to determine the size and position of any subviews. Subclasses can override this method as needed to perform a more precise layout of their subviews. You should override this method only if the autoresizing and constraint-based behaviors of the subviews do not offer the behavior you want. You can use your implementation to set the frame rectangles of your subviews directly.


The priority really comes into play only if two different constraints conflict. The system will give importance to the one with higher priority.

What is intrinsic content size

The intrinsic content size can define the view’s height and width or both.

Content Hugging

The content hugging pulls the views inwards so that it fits around the content. The one view with higher horizontal content hugging priority will not grow beyond its content size

Content compression

The content compression resistance pushes the view outwards so that it doesn’t clip the content. Set the buttons horizontal Compression Resistance Priority to 1000. And now, change the priority of the width constraint to any value between 0 to 999. Setting a higher value means that we don’t want the view to shrink smaller than the intrinsic content size.

⚠️ **GitHub.com Fallback** ⚠️