Skip to content

Instantly share code, notes, and snippets.

View ecaepsey's full-sized avatar
🏠
Working from home

Damir Aushenov ecaepsey

🏠
Working from home
  • Keremet Bank
  • Kyrgyzstan
View GitHub Profile
@oguzhanvarsak
oguzhanvarsak / questions.md
Last active April 18, 2024 18:50
Interview Questions for iOS Developers

Interview Questions for iOS Developers

1. Classes vs structs

In Swift, structs are value types whereas classes are reference types. When you copy a struct, you end up with two unique copies of the data. When you copy a class, you end up with two references to one instance of the data. It’s a crucial difference, and it affects your choice between classes or structs. (+ Class extendable, struct does not.)

2. What’s the difference between var and let? Which one would you choose for properties in a struct and why?

Both let and var are for creating variables in Swift. let helps you create immutable variables (constants) while on the other hand var creates mutable variables.

3. What does the mutating keyword mean?

The mutating keyword lets callers know that the method is going to make the value change.

@hamdan
hamdan / button.swift
Last active September 20, 2023 07:17
Single Select Button Groups using rxswift
private let disposeBag = DisposeBag()
let selectedButton = Observable.from(
filterButtons.map { button in
button.rx.tap.map { button }
}
).merge()
filterButtons.forEach { button in
selectedButton.map { $0 == button }
@iamchiwon
iamchiwon / ASAuthorizationControllerProxy.swift
Last active July 6, 2023 07:37
 Sign in with Apple + Rx
import AuthenticationServices
import RxCocoa
import RxSwift
import UIKit
@available(iOS 13.0, *)
extension ASAuthorizationController: HasDelegate {
public typealias Delegate = ASAuthorizationControllerDelegate
}
@zfael
zfael / load-test.ts
Last active February 20, 2022 21:35
Node script for load testing!
/**
* Usage
* - npm install loadtest
* - npx ts-node load-test.ts
*/
import loadtest from 'loadtest';
const method = 'GET';
import Foundation
import AuthenticationServices
@available(iOS 13.0, *)
open class AppleSignInManager: NSObject {
static let shared: AppleSignInManager = AppleSignInManager()
var userData: LoginUserData? = nil
var isShareImageVideo: Bool = false
@hamdan
hamdan / Rotate.swift
Created March 13, 2020 12:10
Rotate Only One ViewController to Landscape Orientation
// 1. First of all, you need to make sure “Device Orientation” only on ‘Portrait’ mode.
//2. Add these two functions to AppDelegate, which helps you deal with embed in nav bar/tab bar situation mentioned above:
protocol Rotatable: AnyObject {
func resetToPortrait()
}
extension Rotatable where Self: UIViewController {
func resetToPortrait() {
@markusfassbender
markusfassbender / GridStackView.swift
Last active December 8, 2022 05:15
GridStackView
import UIKit
class GridStackView<T>: UIStackView where T: UIView {
// MARK: Properties
var numberOfColumns: Int = 2
var items: [T] {
arrangedSubviews.flatMap { view -> [T] in
@iamchiwon
iamchiwon / Rx+Codable.swift
Created November 22, 2019 12:14
RxSwift extension for Codable
import RxSwift
extension ObservableType {
public func mapObject<T: Codable>(type: T.Type) -> Observable<T> {
return flatMap { (data) -> Observable<T> in
if let data = (data as? (HTTPURLResponse, Data))?.1 {
return try self.mapObject(type: type, data: data)
} else if let json = (data as? (HTTPURLResponse, Any))?.1 {
return try self.mapObjectJSON(type: type, json: json)
} else {
enum TestError: Error {
case test
}
extension ObservableType {
func retryWhen(
predicate: @escaping (Error) -> Bool,
maxRetry: Int,
extension String {
func foregroundColor(_ color: UIColor) -> NSAttributedString {
NSAttributedString(string: self, attributes: [.foregroundColor : color])
}
func background(_ color: UIColor) -> NSAttributedString {
NSAttributedString(string: self, attributes: [.backgroundColor: color])
}
func underline(_ color: UIColor, style: NSUnderlineStyle = .single) -> NSAttributedString {
NSAttributedString(string: self, attributes: [.underlineColor: color, .underlineStyle: style.rawValue])
}