We are About to Hire You, But…

Whenever you assign a class instance to a property, constant, or variable, that property, constant, or variable makes a strong reference to the instance. A weak reference is a reference that does not keep a strong hold on the instance it refers to, and so does not stop ARC from disposing of the referenced instance. Unowned reference does not keep a strong hold on the instance it refers to. Unlike a weak reference, however, an unowned reference is used when the other instance has the same lifetime or a longer lifetime. I did not trouble to list questions from easy to difficult. It totally shows up how it comes to my mind, unordered. 

Let’s fire it up!

 

1. How does ARC works?

With iOS 5, Apple released ARC, which means Automatic Reference Counting, is a really nice-to-have feature on behalf of iOS Development. It decreases or increases reference count of an object by regarding relationship with another objects. For example, when you create an object, reference count becomes 1. Each strong reference between objects increments reference count by 1. Whenever it reaches to 0, object can be deallocated. ARC only performs to instances of classes. Because Class creates reference-type instances otherwise, enum or struct create value-type instances.

Whenever you assign a class instance to a property, constant, or variable, that property, constant, or variable makes a strong reference to the instance. A weak reference is a reference that does not keep a strong hold on the instance it refers to, and so does not stop ARC from disposing of the referenced instance. unowned reference does not keep a strong hold on the instance it refers to. Unlike a weak reference, however, an unowned reference is used when the other instance has the same lifetime or a longer lifetime.

3. What is a memory leak?

Memory that was allocated at some point, but was never released and is no longer referenced by your app. Since there are no references to it, there’s now no way to release it and the memory can’t be used again.

4. How does retain/strong reference cycle occur?

Even ARC works like a stonker, You can still have some pitfalls.

It’s possible to write code in which an instance of a class never gets to a point where it has zero strong references. This can happen if two class instances hold a strong reference to each other, such that each instance keeps the other alive. This is known as a strong reference cycle.

5. What is the difference and common things between Class and Struct?

Classes and structures in Swift have many things in common. Both can:

- Define properties to store values

- Define methods to provide functionality

- Define subscripts to provide access to their values using subscript syntax

- Define initializers to set up their initial state

- Be extended to expand their functionality beyond a default implementation

- Conform to protocols to provide standard functionality of a certain kind

Main difference between them is, Classes are reference types, Structures are value types.

6. What is the definition of Protocol and Extension?

protocol defines a blueprint of methods, properties, and other requirements that suit a particular task or piece of functionality. The protocol can then be adopted by a class, structure, or enumeration to provide an actual implementation of those requirements. Any type that satisfies the requirements of a protocol is said to conform to that protocol.

Extensions add new functionality to an existing class, structure, enumeration, or protocol type. This includes the ability to extend types for which you do not have access to the original source code (known as retroactive modeling). Extensions are similar to categories in Objective-C. (Unlike Objective-C categories, Swift extensions do not have names.) 

7. What is CocoaPods?

CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. It has over 47 thousand libraries and is used in over 3 million apps. CocoaPods can help you scale your projects elegantly.

8. Is there any open source library that you get advantage of it in your application?

  • Alamofire and AlamofireImage — Network Layer
  • Spring — Animation UI
  • Reel search — Search UI

You can express more libraries for different categories.

Thanks for reading!

Leave a Comment