Open in app
Home
Notifications
Lists
Stories

Write
Arman Abkar
Arman Abkar

Home
About

Jan 4

@UseAutoLayout

A property wrapper that enables Auto Layout on views — When we are writing the views and constraints pragmatically, we also need to set the translatesAutoresizingMaskIntoConstraints for each view to false, so that the view’s autoresizing mask won’t be translated into Auto Layout constraints: label.translatesAutoresizingMaskIntoConstraints = false To make our lives easier, we are going to write a property wrapper that prevents us from writing the long and a little bit ugly expression above for each view we create. Property wrappers were introduced in Swift 5.1 and are also heavily used in SwiftUI (e.g. @State, @Binding, @Published, etc).

Swift

1 min read


Dec 31, 2021

Inverting Binary Tree in Swift

LeetCode #226 challenge: Given a binary tree, write an algorithm to invert the tree and return its root — Given the root of a binary tree, invert the tree, and return its root. Example: Input: root = [4,2,7,1,3,6,9] Output: [4,7,2,9,6,3,1] This challenge can be easily solved recursively. We need to write a method that inverts the given binary tree by swapping the left and right nodes and recursively performing the…

Swift

2 min read

Inverting Binary Tree in Swift
Inverting Binary Tree in Swift

Nov 14, 2021

Delegate Pattern In Swift

Delegation is a design pattern that enables a class or structure to hand off (or delegate) some of its responsibilities to an instance of another type — Delegation is a design pattern that enables a class or structure to hand off (or delegate) some of its responsibilities to an instance of another type. Swift Official Documentation This pattern is implemented by defining a delegate protocol that encapsulates all the requests, a delegator who hands off the requests…

I OS

3 min read

Delegate Pattern In Swift
Delegate Pattern In Swift

Nov 11, 2021

Access Control in Swift

Restricts access to parts of your code from code in other source files and modules — Access control restricts access to parts of your code from code in other source files and modules. This feature enables you to hide the implementation details of your code and to specify a preferred interface through which that code can be accessed and used. The Swift Documentation Swift offers 5…

Swift

2 min read

Access Control in Swift
Access Control in Swift

Oct 23, 2021

Essential Xcode Shortcuts

The most useful Xcode shortcuts to boost your productivity and save you time — Software developers spend a significant amount of time in IDEs, so it’s worth becoming an expert in using them. Therefore let’s have a look at some of the most useful Xcode shortcuts which will boost your productivity and save you a lot of time:

Xcode

2 min read

Essential Xcode Shortcuts
Essential Xcode Shortcuts

Sep 30, 2021

Optionals In Swift

A type that represents either a wrapped value or nil, the absence of a value. — Swift Official Documentation: Swift is a type-safe language. A type-safe language encourages you to be clear about the types of values your code can work with. In Swift, all the (non-optional) variables and constants need to have a value before they can be used. ِBut sometimes, we are not sure…

Swift

3 min read

Optionals In Swift
Optionals In Swift

Sep 12, 2021

Map, Filter, and Reduce in Swift

Higher-Order Functions such as map, filter, reduce, flatMap, and compactMap for functional programming — Swift, like other modern programming languages, already has some functional features and in this tutorial, we are going to learn one of them, higher-order functions which can help us write cleaner and more testable code. But what exactly are higher-order functions? Higher-order functions are just functions that take another function…

Swift

3 min read


Sep 4, 2021

Reverse String in Swift

LeetCode #344 challenge: Write a function that reverses a string. — Write a function that reverses a string. The input string is given as an array of characters s. You must do this by modifying the input array in-place with O(1) extra memory. Input: s = ["h","e","l","l","o"] Output: ["o","l","l","e","h"] This challenge can be easily solved with a built-in method but it…

Swift

2 min read


Sep 1, 2021

Two-Sum Problem in Swift

LeetCode #1 challenge: Given an array of numbers and a target, return indices of the two numbers such that they add up to target — Given an array of integers numsand an integer target, return indices of the two numbers such that they add up to the target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any…

Swift

2 min read

Arman Abkar

Arman Abkar

 Software Developer, armanabkar@gmail.com

Help

Status

Writers

Blog

Careers

Privacy

Terms

About

Knowable