General iOS, CS questions and interview prep resources.
-
iOS Interview Questions for Senior Developers (useful even if you're not senior yet)
| import SwiftUI | |
| struct TaskTrigger<T: Equatable>: Equatable { | |
| fileprivate enum TaskState<S: Equatable>: Equatable { | |
| case inactive | |
| case active(value: S, uniqueId: UUID? = nil) | |
| } | |
| fileprivate var state: TaskState<T> = .inactive |
| func scrollViewDidScroll(_ scrollView: UIScrollView) { | |
| for (i, view) in scrollView.subviews.enumerated() { | |
| var ty = 0.0 | |
| if scrollView.contentOffset.y < 0 { | |
| // We're scrolling past the top of the scroll view. | |
| // Translate each item in the scroll view by some amount based on its index and scroll offset. | |
| ty = CGFloat(i) * abs(offsetY) / 8.0 * pow(1.12, CGFloat(i)) | |
| } | |
| view.transform = CGAffineTransform(translationX: 0, y: ty) | |
| } |
| // | |
| // Color+Extension.swift | |
| // Helpers pack with: | |
| // | |
| // 1 - encode/decode RGBA | |
| // 2 - accessibleFontColor depends on background color | |
| // 3 - isLightColor - color lightness detection | |
| // | |
| // Created by Alexo on 19.12.2020. | |
| // |
General iOS, CS questions and interview prep resources.
iOS Interview Questions for Senior Developers (useful even if you're not senior yet)
| import SwiftUI | |
| extension Calendar { | |
| func generateDates( | |
| inside interval: DateInterval, | |
| matching components: DateComponents | |
| ) -> [Date] { | |
| var dates: [Date] = [] | |
| dates.append(interval.start) |
| name: Example iOS Build | |
| on: | |
| push: | |
| branches: | |
| - development | |
| jobs: | |
| build-ios: | |
| runs-on: macos-latest |
| import UIKit | |
| class RectangularDashedView: UIView { | |
| @IBInspectable var cornerRadius: CGFloat = 0 { | |
| didSet { | |
| layer.cornerRadius = cornerRadius | |
| layer.masksToBounds = cornerRadius > 0 | |
| } | |
| } |
| // | |
| // EmbedsViewController.swift | |
| // | |
| // Created by Evan Sobkowicz. | |
| // Copyright © 2019 Twitter. All rights reserved. | |
| // | |
| import UIKit | |
| import WebKit | |
| import SafariServices |
| import Foundation | |
| import CoreTelephony | |
| struct PhoneHelper { | |
| static func getCountryCode() -> String { | |
| guard let carrier = CTTelephonyNetworkInfo().subscriberCellularProvider, let countryCode = carrier.isoCountryCode else { return "+" } | |
| let prefixCodes = ["AF": "93", "AE": "971", "AL": "355", "AN": "599", "AS":"1", "AD": "376", "AO": "244", "AI": "1", "AG":"1", "AR": "54","AM": "374", "AW": "297", "AU":"61", "AT": "43","AZ": "994", "BS": "1", "BH":"973", "BF": "226","BI": "257", "BD": "880", "BB": "1", "BY": "375", "BE":"32","BZ": "501", "BJ": "229", "BM": "1", "BT":"975", "BA": "387", "BW": "267", "BR": "55", "BG": "359", "BO": "591", "BL": "590", "BN": "673", "CC": "61", "CD":"243","CI": "225", "KH":"855", "CM": "237", "CA": "1", "CV": "238", "KY":"345", "CF":"236", "CH": "41", "CL": "56", "CN":"86","CX": "61", "CO": "57", "KM": "269", "CG":"242", "CK": "682", "CR": "506", "CU":"53", "CY":"537","CZ": "420", "DE": "49", "DK": "45", "DJ":"253", "DM": "1", "DO": "1", "DZ": "213", "EC": "593" |
| // | |
| // UITextViewPlaceholder.swift | |
| // TextViewPlaceholder | |
| // | |
| // Copyright (c) 2017 Tijme Gommers <tijme@finnwea.com> | |
| // | |
| // Permission is hereby granted, free of charge, to any person obtaining a copy | |
| // of this software and associated documentation files (the "Software"), to deal | |
| // in the Software without restriction, including without limitation the rights | |
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |