Skip to content

Instantly share code, notes, and snippets.

View lourintp's full-sized avatar

Thiago Lourin lourintp

  • Maringá - PR - Brazil
View GitHub Profile
@lourintp
lourintp / Minesweeper.swift
Created February 16, 2023 20:37
Minesweeper Game
// Define the size of the board
let row = 8
let column = 8
// Define the number of mines
let numberOfMines = 10
// Create an 2D array to represent the board
var board = [[Int]](repeating: [Int](repeating: 0, count: 8), count: 8)
protocol TextFieldValidatorStrategy {
func validate(_ field: UITextField) -> Bool
}
struct TextFieldValidator {
let strategy: TextFieldValidatorStrategy
func validate(_ field: UITextField) -> Bool {
if let _ = field.text {
@lourintp
lourintp / TextFieldValidator.swift
Created February 13, 2020 19:00
Example of a UITextField validator that can be replaced for a Strategy Pattern
import UIKit
import Foundation
struct TextFieldValidator {
enum FieldValidationType {
case empty
case sizeGreaterThenThree
case onlyNumbers
}