Closures, Extensions and Generics in Swift

Closures Closures are self contained lines of code that can be passed around the application and similar to blocks in Objective-C. A typical closure syntax in Swift looks as shown below Closure Syntax { (parameters) -> return type in statements } Example closure in Swift var greetings = { (name:String, message:String) -> (String) in message […]

Dependency Injection in Swift

Dependency injection is a design pattern that lets you to pass the dependencies for the object instances instead of creating the them inside the instances. Let us see this with an example of an app that manages Expenses. In an Expense app we might have different components like ExpenseManager – Responsible of managing business logic […]

Memory management in Swift

Memory management in Swift is done by Automatic Reference Counting or ARC. Whenever a variables holds an instance of an object the memory count for that object increases by 1. And when variable becomes out of scope or set to nil, the memory count decreases 1. class Teacher { var name: String? var course: String? […]

What are the different lifecycle methods in a typical UIViewController?

Here is the list of Lifecycle methods in a ViewController are viewDidLoad – Called after the view controller’s view hierarchy has been loaded into memory. It is used for initial setup, such as creating and configuring UI elements. viewWillAppear – Called just before the view is about to be added to the view hierarchy and […]

Explain App Life Cycle

The app life cycle refers to the sequence of steps that app takes when an user launches an app until it terminates. Understanding the life cycle will help the developer to manage app behaviour and proper allocation and deallocation of resources. Image Credit :- Apple Not Running – Initial stage when the app is not […]

Difference between Delegate and Notifications in iOS

Delegates Notifications One-to-one communication One-to-many or many-to-many communication Customized behavior Broadcasting information/events Delegate object holds a reference Observing objects don’t need references Specific responsibilities/tasks Widely distributed information/events Tight coupling between objects Loose coupling between objects Object needs to know its delegate Posting object doesn’t know receivers Callbacks, data source protocols, event handling Application-wide event handling

What is the difference between Swift and Objective-C

Objective-C Swift Syntax C style syntax with small-style message passing Modern and Concise Syntax Safety More permissive and allows runtime errors Strong focus on safety – enforcing memory safety, nullability check, type safety Performance Not faster than Swift Swift uses advanced compiler optimisation techniques. Interoperability Compatible with both C and C++ Swift needs bridging headers […]

Swift Interview Questions

Listed below are some of topics to be familiar before attending an iOS//Swift interviews. These are very trivial questions but in future this space will updated with more scenario based questions What are the different app states? What is JSON? What do you mean by REST? Difference between class and struct? What are Optionals? Difference between […]