Swift API Design guidelines Swift.org - API Design Guidelines #weblinks https://www.swift.org/documentation/api-design-guidelines/ layout: page title: API Design Guidelines official_url: https://swift.org/documentation/api-design-guidelines/ redirect_from: /documentation/api-design-guidelines.html {% capture expand %}{::nomarkdown} {:/nomarkdown}{% endcapture %} {% assign detail = ββ %} {% assign enddetail = ββ %} Table of Contents {:.no_toc} TOC {:toc} Fundamentals Clarity at the point of use is your most important goal. Entities such as methods and properties are declared only once but used repeatedly....
Learning/DesignPatterns
Design Patterns implemented in Swift 5.0 A short cheat-sheet with Xcode 10.2 Playground (Design-Patterns.playground.zip). π¨π³δΈζη π· Project started by: @nsmeme (Oktawian Chojnacki) π· δΈζηη± @binglogo (ζ£ζ£ε½¬) ζ΄ηηΏ»θ―γ π How to generate README, Playground and zip from source: GENERATE.md print("Welcome!") Table of Contents Behavioral Creational Structural π Chain Of Responsibility π° Abstract Factory π Adapter π« Command π· Builder π Bridge πΆ Interpreter π Factory Method πΏ Composite π« Iterator π Monostate π§ Decorator π Mediator π Prototype π FaΓ§ade πΎ Memento π Singleton π Flyweight π Observer β Protection Proxy π State π¬ Virtual Proxy π‘ Strategy π Visitor π Template Method Behavioral In software engineering, behavioral design patterns are design patterns that identify common communication patterns between objects and realize these patterns....
learning/swift-dsa
DSA If the input array is sorted then: use Binary search or Two pointers patterns/technique. If asked for all permutations or subsets then use the Backtracking technique. If given a tree then use DFS or BFS. If given a graph then use DFS or BFS. If given a linked list then use the Two Pointers technique with probably the Fast/Slot Pointers technique. If recursion is banned then use a Stack. If must solve in-place then you can Swap corresponding values or Store one or more different values in the same pointer....
Learning/Architecture
iOS Architecture Analytics Architecture MVVM The MVVM (Model-View-ViewModel) architecture is a design pattern that is used to structure the code in iOS apps. It is similar to the MVC (Model-View-Controller) architecture, but it introduces a new component called the ViewModel. The ViewModel is responsible for exposing data to the View and facilitating communication between the Model and the View. One of the main benefits of using MVVM is that it helps to separate the business logic of an app from the user interface, which makes it easier to develop and maintain the app over time....
programming/iOS/practice
// Arrays import Foundation import XCTest // 1,2,5 11 // Uber set class Solution { class Solution { func partitionString(s: String) -> [String] { var partitions = [String]() var currentPartition = "" var seenLetters = Set<Character>() for letter in s { if seenLetters.contains(letter) { partitions.append(currentPartition) currentPartition = "" seenLetters.removeAll() } currentPartition += String(letter) seenLetters.insert(letter) } if !currentPartition.isEmpty { partitions.append(currentPartition) } return partitions } func topKFrequent(nums: [Int], k: Int) -> [Int] { // Create a dictionary to keep track of the frequency of each element var frequencyDict = [Int: Int]() for num in nums { frequencyDict[num, default: 0] += 1 } // Create a min heap to store the elements based on their frequency var heap = MinHeap<(Int, Int)> { $0....
AccessControl
Access Control Manage the visibility of code by declaration, file, and module. 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. You can assign specific access levels to individual types (classes, structures, and enumerations), as well as to properties, methods, initializers, and subscripts belonging to those types....
AdvancedOperators
Advanced Operators Define custom operators, perform bitwise operations, and use builder syntax. In addition to the operators described in doc:BasicOperators, Swift provides several advanced operators that perform more complex value manipulation. These include all of the bitwise and bit shifting operators you will be familiar with from C and Objective-C. Unlike arithmetic operators in C, arithmetic operators in Swift donβt overflow by default. Overflow behavior is trapped and reported as an error....
AutomaticReferenceCounting
Automatic Reference Counting Model the lifetime of objects and their relationships. Swift uses Automatic Reference Counting (ARC) to track and manage your appβs memory usage. In most cases, this means that memory management βjust worksβ in Swift, and you donβt need to think about memory management yourself. ARC automatically frees up the memory used by class instances when those instances are no longer needed. However, in a few cases ARC requires more information about the relationships between parts of your code in order to manage memory for you....
BasicOperators
Basic Operators Perform operations like assignment, arithmetic, and comparison. An operator is a special symbol or phrase that you use to check, change, or combine values. For example, the addition operator (+) adds two numbers, as in let i = 1 + 2, and the logical AND operator (&&) combines two Boolean values, as in if enteredDoorCode && passedRetinaScan. Swift supports the operators you may already know from languages like C, and improves several capabilities to eliminate common coding errors....
ClassesAndStructures
Structures and Classes Model custom types that encapsulate data. Structures and classes are general-purpose, flexible constructs that become the building blocks of your programβs code. You define properties and methods to add functionality to your structures and classes using the same syntax you use to define constants, variables, and functions. Unlike other programming languages, Swift doesnβt require you to create separate interface and implementation files for custom structures and classes. In Swift, you define a structure or class in a single file, and the external interface to that class or structure is automatically made available for other code to use....