Skip to content

Instantly share code, notes, and snippets.

@arslanbilal
arslanbilal / multipleRequest.swift
Last active August 21, 2023 21:55
Multiple Request with Dispatch Group
let firstRequestGroup = DispatchGroup()
let secondRequestGroup = DispatchGroup()
for () {
requestGroup.enter()
firstRequest() {
print("DEBUG: FIRST Request")
if success {
requestGroup.enter()
secondRequest() {
@arslanbilal
arslanbilal / UIAlertController+TextField.swift
Last active September 24, 2018 19:31 — forked from ole/UIAlertController+TextField.swift
A UIAlertController with a text field and the ability to perform validation on the text the user has entered while the alert is on screen. The OK button is only enabled when the entered text passes validation. More info: https://oleb.net/2018/uialertcontroller-textfield/
import UIKit
/// A validation rule for text input.
public enum TextValidationRule {
/// Any input is valid, including an empty string.
case noRestriction
/// The input must not be empty.
case nonEmpty
/// The enitre input must match a regular expression. A matching substring is not enough.
case regularExpression(NSRegularExpression)
@arslanbilal
arslanbilal / .swiftlint.yml
Last active January 7, 2024 10:55
Default swift lint file for projects
disabled_rules: # rule identifiers to exclude from running
# Number of function parameters should be low.
- function_parameter_count
# Type bodies should not span too many lines.
- type_body_length
# Complexity of function bodies should be limited.
- cyclomatic_complexity
@arslanbilal
arslanbilal / PlistDecoder.swift
Last active December 14, 2018 10:56
PropertyListDecoder with Codable
//
// PlistDecoder.swift
// Bilal Arslan
//
// Created by BILAL ARSLAN on 14.12.2018.
// Copyright © 2018 BILAL ARSLAN. All rights reserved.
//
import Foundation
@arslanbilal
arslanbilal / NetworkActivity.swift
Created December 14, 2018 10:57
NetworkActivity
//
// JuxNetworkActivityIndicator.swift
// Bilal Arslan
//
// Created by BILAL ARSLAN on 14.12.2018.
// Copyright © 2018 BILAL ARSLAN. All rights reserved.
//
import UIKit
@arslanbilal
arslanbilal / contactPropertySelection.swift
Last active April 4, 2023 16:03
ContactsUI select contact property
import ContactsUI
class ExampleViewController: UIViewController {
private func dispayContacts() {
let contactPicker = CNContactPickerViewController()
contactPicker.delegate = self
contactPicker.displayedPropertyKeys = [CNContactGivenNameKey, CNContactPhoneNumbersKey]
contactPicker.predicateForEnablingContact = NSPredicate(format: "phoneNumber.@count > 0")
contactPicker.predicateForSelectionOfContact = NSPredicate(value: false)