Adapter pattern in Swift

Updated on 31st Aug 2019, 02:48 AM GMT 5:30+

Image for post
Image for post
Thanks to Chris Grooms for the great illustration!

Prerequisites — This tutorials series requires an intermediate level of expertise in object-oriented programming. You should have basic knowledge about class, object, constructor, inheritance, value and reference type. An Intermediates will gain knowledge and experts will sharpen his or her knowledge by reading this series from start to finish.

What is an Adapter?

An adapter is a physical device that allows one hardware or electronic interface to be adapted to another hardware or electronic interface without loss of functionality.

Adapters are used when you have one form of input and you want to access something that cannot take your form of input. …


Perform undo-redo actions in a more simple way

Updated on 28th September 2019, 10:15 AM GMT 5:30+

Image for post
Image for post

Have you heard about the UndoManager or NSUndoManager before? If your answer is,

  • Yes, That’s great. You are one of very few developers who know about UndoManager, Let’s explore it in details together.
  • No, Don’t worry. Follow this article, you will learn everything about UndoManager.

Let’s understand the UndoManager,

  1. What is UndoManager?
  2. What are the benefits of UndoManager?
  3. Understand UndoManager with a real-life example.
  4. How does undo and redo works in UndoManager with almost zero efforts?
  5. Download full-example from Github link available at the bottom.

I found that many of the developers required to implement undo/redo actions during development, usually in photo editing or video editing applications.
Suppose we are developing a photo editing application with Undo-Redo functionality in the editing screen. …


- The introduction of Redux | ReSwift

Updated on 10th April 2019, 8:21 AM GMT 5:30+

Image for post
Image for post

Welcome to the new article series about Redux | ReSwift, the latest programming architecture and hottest libraries for front-end development.

Have you heard about Redux before?

  • If the answer is Yes, That’s great. This article is for you to gain more knowledge.
  • If the answer is No, Don’t worry. You will learn in-depth about Redux | ReSwift starting from
    - Introduction
    - What was the problem? Why redux introduced?
    - How it solves the problem?
    - Why do you need to use Redux?
    - Practical use of Redux | ReSwift with tutorials

Introduction:

Redux is the latest programming architecture introduced by Dan Abramov and Andrew Clark , pre-released in June 2015. It was inspired by Facebook’s Flux and functional programming language Elm. Redux is a predictable state container, a data-flow architecture for JavaScript apps. …


Singleton Pattern: pure-singleton and semi-singleton design pattern in Swift

Updated on 4th April 2019, 12:21 AM GMT 5:30+

Image for post
Image for post

Prerequisites — This blog series requires an intermediate level of expertise in object-oriented programming. You should have basic knowledge about class, object, constructor, inheritance, value and reference type. An Intermediates will gain knowledge and experts will sharpen his or her knowledge by reading this series from start to finish.

Singleton class

In object-oriented programming, a singleton class is a class that can have only one object during the whole life-cycle of an application or project.

Singleton design pattern is a part of iOS Applications life-cycle code. For example, in an iOS project, the UIApplication class is the best example of a singleton class, which is created by the iOS system on app launch and passed to the AppDelegate as a parameter in application(_:didFinishLaunchingWithOptions:)method. …


Builder pattern — Faceted and Fluent

Updated on 2nd October 2019, 02:10 AM GMT 5:30+

Image for post
Image for post
Many thanks to Uran for this great illustration!

Prerequisites — This blog series requires an intermediate level of expertise in object-oriented programming. You should have basic knowledge about class, object, constructor, inheritance, value and reference type. An intermediate will gain knowledge and experts will sharpen his or her knowledge by reading this series from start to finish.

Design patterns are used to represent the best practices adopted by the experienced object-oriented software developer community.

The builder design pattern helps us to build an object in a more simpler and readable way. …


Part-5 — Protocol as a super-type

Updated on 17th December 2018, 1:34 AM GMT 5:30+

Image for post
Image for post

Welcome to the 5th part of this series, In-case you missed previous parts, I will strongly suggest you that first coverup the essential concepts from
Part-1: What is type-casting and class-types?
Part-2 — confirming a protocol
Part-3 — Protocol composition
Part-4 — My rule of thumb for possible data types

Where protocol should be used?

The common use of protocol is for delegate and datasources.
Example is UITableDelegate and UITableViewDatasource.

UITableDelegate, UITableViewDatasource both are protocols. You can also create your custom protocols to pass and retrieve data from one ViewController to other ViewController. …


Part-4 — My rule of thumb for possible data types

Updated on 17th December 2018, 1:33 AM GMT 5:30+

Image for post
Image for post

Welcome to the 4th part of this series, In-case you missed previous parts, I will strongly suggest you that first coverup the essential concepts from
Part-1: What is type-casting and class-types?
Part-2 — confirming a protocol
Part-3 — Protocol composition

Before we dive deep into the understanding of my thumb rule of data types, let’s first clear the concept of AnyObject.

What is AnyObject?

AnyObject is an empty protocol available in Swift. The protocol to which all classes implicitly conform.

We can store any class instance with AnyObject type.

store any class instance with AnyObject…


5th June 2018 09:30 PM GMT 5:30+

Image for post
Image for post

Swift 4.2 — Major release

Only the greatest developers will survive
- Hitendra Solanki inspired by Charles Darwin

  • XCode 10 -Swift 4.2
  • Faster build process with XCode 10 and Swift 4.2
  • Big improvements in ARC call managed by system — now we have less ARC calls only at start of scope and at the end of scope.
  • Now code size reduced with 10% to 30%
  • CaseIterable Protocol to Iterate all Cases of Enums
  • Array of Elements is now automatically Equatable if element is equatable
  • Struct and Classes are automatically Equatable and Hashable if all the elements of struct or class is equatable or Hashable respectively, Same for enum with tuple values…


4th June 2018 10:30 PM GMT 5:30+

Only the strongest apps will survive
- Apple Inc.

Only the greatest developers will survive
- Hitendra Solanki inspired by Charles Darwin

Image for post
Image for post

iOS

Image for post
Image for post
  • iOS 12 — Smooth and faster performance
  • New USDZ File Format — 3D Object file of AR
  • iOS12 Navtive “Measure App
  • ARKit 2 — improved face tracking, 3D Object Detection and more
  • Reimagined Photo App — We can search in photo now!
  • Shortcuts App — Siri — Enable custom search phrases, Shortcuts. We can simply consider it Group Actions
  • Redesigned stock app, now available on iPad too.
  • Redeveloped Voice memo app, now available on iPad too. …


Part-3 — Protocol composition

Updated on 14th July 2018, 12:45 PM GMT 5:30+

Image for post
Image for post

Welcome to the 3rd part of this series, In-case you missed first or second part, I will strongly suggest you that first coverup the essential concepts from
Part-1: What is type-casting and class-types?
Part-2 — confirming a protocol

After completing part-1 and part-2,
Now you are ready with essential skills to understand this blog.

I ended part-2 with unanswered question, now it’s time to answer your question

What is protocol composition?

Combining multiple protocols as a group and giving them a single name is know as protocol composition. This is handy when you needs to confirm same group of protocols many times in your project like UICollectionViewDelegate and UICollectionViewDatasource. …

About

Hitendra Solanki

Software Engineer at PhonePe India, {Self-taught Developer by passion, Quick Learner, Mentor, blogger, TeamLead} GitHub: https://github.com/hitendradeveloper

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store